Null reference exception on main form. Help please...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

..I created a VB.net Windows application using Form1.vb as my one and only
Windows form. When I go to run the application I receive the following
exception: "An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an object."

When I opened up the Windows Form Designer generated code region I have a
constructor function that looks like this:
"Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub"

Any ideas on how to remedy this?
 
Jim said:
.I created a VB.net Windows application using Form1.vb as my one and only
Windows form. When I go to run the application I receive the following
exception: "An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an object."

When I opened up the Windows Form Designer generated code region I have a
constructor function that looks like this:
"Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub"

Any ideas on how to remedy this?

Firstly, find out exactly where the exception is. Look at the stack
trace. That should give you a good idea.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Back
Top