Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
clicked build project and

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

1 solution

Here is my advice: run it under debugger. When execution is stopped where the exception is thrown, see Exception.InnerException for detail. Those details are so informative (in contrast to your question), that most developers can immediately see where they screwed up. :-)

If you won't see it immediately, set a breakpoint immediately before the point where the exception is thrown. Look at the next statement. Use "Quick view" (in context menu) for all the variables involved. I bet one of them is null, but your next like does not take in into account. When you see this, you will certainly see what to do with that.

Good luck,
—SA
 
Share this answer
 
v2
Comments
Heer91 5-Apr-12 0:58am    
I am sorry but i am very new to this.
When i tried to look at inner exception in trouble shooting tips it opens in the web browser and of no use.I am not understanding any thing.

Can you please tell me the reason for this exception?I never occured before and once i clicked on Build "My project" option this started happening.
Sergey Alexandrovich Kryukov 5-Apr-12 1:16am    
The reason is null. You dereference some variable of reference type, but it is null. For example:
string badValue = null;
int position = badValue.IndexOf(","); //whatever you do, it will throw this exception.
--SA
Heer91 5-Apr-12 1:00am    
And this occurred when i tried to refer to a form.Is it fine if we refer to a form directly without creating it's instance?
Sergey Alexandrovich Kryukov 5-Apr-12 1:16am    
What do you mean "fine"? It makes no sense in principle!
--SA
Heer91 5-Apr-12 1:06am    
If by mistake I have deleted the initialization code then I will I come to know?
And what should i do to recover it?

If you are online please help me.

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