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

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?
 
J

Jon Skeet [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top