System Null Exception always shows

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

Guest

When I compile and run my application, even thought a form that created by
Designer, my system always shows this error:

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

It always happens and I cannot debug to that code, it said the code not
available. Anyone met this problem yet? Who can help me?

My system is Windows XP SP2.

Thanks in advance.
 
Not sure if this helps or not but I just got done tracking the same error
down on my application. The offending code was a property in a custom
control. For some reason the set method was being run at compile time even
though I wasn't directly calling it. I'm guessing this is how .net
intializes components?? In my set property method I had reference to an
object that defaulted to null. Once I put a condition statement in front of
this:

set {
if (foo != null)
....
}

things worked fine.
 
Yes, the visual designer initializes *all* properties of a control unless:

- The property is marked with the
[DesignerSerialisationVisibility(DesignerSerialisationVisibility.Hidden)]
attribute

or

- The property is marked with the [DefaultValue(xyz)] attribute and the
property has the value xyz when the object is initialized.
 
Ok, thanks. However, how to solve this problem? It make me tired, at any time
I start my application, it always said like that. I mean all .NET
applications have got the same problem. What can I do here? Reinstall Visual
Studio.Net, Windows XP SP2 or any thing else?

For more information, when I choose debug with CLR and Native it shows:

An unhandled exception of type 'System.NullReferenceException' occurred in
Unknown Module.
Additional information: Object reference not set to an instance of an object.

there is an interested thing:
7C90EB90 nop
7C90EB91 nop
7C90EB92 nop
7C90EB93 nop
7C90EB94 ret <== this line error :(
7C90EB95 lea esp,[esp]
7C90EB9C lea esp,[esp]

This always happens.
 
Back
Top