Wednesday, May 03, 2006 8:22 AM
Our application has 2 main windows it can be changed using the combo box.When i try to change to another window i am getting this exception.When i try to catch the exception it is caught only after Application.Run(context).I dont know where this exception is thrown from.
this is the exception i got...
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at Sys€em.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Forms.FormLoader.Main() in D:\Project\FXCargo\FXCargo\FormLoader.vb:line 117
Please reply a solution for this
Wednesday, May 03, 2006 8:34 AMModerator
You can handle the ApplicationException event, and the ThreadedException event if needed, to catch any exception that occurs in your code.
You should probably post the code in the event handler for the click event, and first try putting a break point in there and stepping through it. F9 sets a breakpoint.
Wednesday, May 03, 2006 9:47 AM
you are telling that yoy are using Combobox for selecting the windows.
I think you are handling that in combobox selected indexchange event.
But this is common error will happen in form initialization.(if you are using combobox selected index/Item change event.)
Check your event with try catch block.
Inside the event use before calling a perticular form check for
For ObjectIf IsNothing(objTemp) = False Then ''Your code End If
for Variable(like string Variable)If IsNothing(strTemp) = False Then If IsDBNull(strTemp) = False Then ''Your code End If End If
Wednesday, May 03, 2006 10:42 AM
My code is inside the try catch block only.Actually for combobox selectedindex changed event, I am calling a function to show the another window.For the first time its working correctly and i am getting the another window opened and the previous one closed but when i try to do it for the second time,i am getting the error and is not caught at the combobox event but i am getting it after the Application.Run(context).
Wednesday, May 03, 2006 11:11 AM
The problem is solved.Actually I have added 4 comboboxes on the window.Now I have removed the newly added combo boxes and now its working properly.
Thank you for ur replies.