Hello people,
I am finding a hard time in resolving the nullreferenceexception my application is throwing.
My application has two forms.
In the first form i am performing the following operations.
1. Fetching values from the database
2. Creating an instance of the second form
3. Making the first form invisible
4. Making the second form visible
5. Navigating to second form by calling a method in which i am
populating the data fetched from database into a list view control
These are the steps that are executed in my application. Now in the first two runs i am able to display fetched data in the second form and navigate back to the first form through a button_click event where in i am making the second form invisible and making the first form visible(only single instance created for both forms). When i perform the operation for the third run the second form is loaded with data and immediately breaks giving the "
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object."
The stack trace is as follows ---
************************************************** ********************
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMethods+IMsoComponentManager. FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopI nner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop( Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at App.SearchCriteria.Main() in D:\App\Search.
vb:line 5The program '[3436] App.exe' has exited with code 0 (0x0).
************************************************** ********************
I have checked the control flow and its complete. The control comes back to the event which fired the search on the first form and after it exits this event this exception is thrown. This occurs every third run i perform a search. In the first two runs i am not facing any problem but in the third run i am facing this exception.
Can any one help me in resolving this issue as i am running short of time.
Thanks in advance
dheeraj