Click here to Skip to main content
15,882,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My program has started giving me this at startup (debug mode in IDE):

An unhandled exception of type 'System.InvalidOperationException' occurred in Penguine 2015.exe

Additional information: An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.


The above is in the exception caption box[?] and takes me to :
Application.Designer.vb

at which I have this code :

VB
<Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
       Protected Overrides Sub OnCreateMainForm()
           Me.MainForm = Global.Program_Plotter_  2015.ProgramPlotter  ' this line is green highlight

       End Sub


When I park the cursor over the "Me.MainForm" I get "Me.MainForm|Nothing"

I have no idea how to resolve this issue. I am a hobbyist with no schooling in programming, and have never seen this before !
Posted
Updated 9-May-15 6:45am
v2
Comments
Valery Possoz 9-May-15 14:19pm    
I can't really tell you the answer as it could be a lot of things... But...

What you need to do is look at the meaning of "Object reference not set to an instance of an object".

Basically it means you are trying to access a property or a method of an object that does not exist.

There are things you can do to make sure this does not happen. For example check for nullity before using a property or method or at least use a try{} catch{}

Also if you run in the debbuger step by step it is quite trivial to find the object that is null... look in the autos window.
mark willetts 9-May-15 14:28pm    
What is "the autos window"?
mark willetts 9-May-15 14:55pm    
I found the autos window (google) but I don't have a clue how to use it!
- [System.InvalidOperationException] {"An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."} System.InvalidOperationException
- [System.InvalidOperationException] {"An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."} System.InvalidOperationException
- base {"An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."} System.SystemException {System.InvalidOperationException}
- base {"An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."} System.Exception {System.InvalidOperationException}
_className null string
- _data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
- [System.Collections.ListDictionaryInternal] {System.Collections.ListDictionaryInternal} System.Collections.ListDictionaryInternal
_syncRoot null object
count 0 int
Count 0 int
head null System.Collections.ListDictionaryInternal.DictionaryNode
mark willetts 9-May-15 15:30pm    
I commented out the entire Public Class Form 1 and hit F5
The blank UI ran, so I uncommented the entire class 1 region at a time. When a region caused the exception, I commented it back out except for the "Region", & "End Region" lines.
Then, 1 event at a time, I uncommented the region.
Found a bogus Global Variable that caused the exception to rise.
It's working now!

Now I know what to do if this ever happens again! :-)

It REALLY pays to use regions for EVERYTHING !!!
mark willetts 9-May-15 15:33pm    
Valery Possoz - Thank You for your help. When I saw what that "Auto" thing was, it gave me the idea to do what I did !
Your help led to the fix! :-)

1 solution

How do I mark a question as "Solved"?
Valery Possoz gets either a "Helpful", or a "Correct". It was her suggestion that led to me solving this.
 
Share this answer
 
Comments
Valery Possoz 9-May-15 17:18pm    
No worries. Glad you found the problem :)
mark willetts 9-May-15 17:22pm    
Thanks anyway ! If you hadn't posted that, and me looking it up, I never would have thought of the idea I did ! :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900