Hi,
I'm developing a GUI with almost all Usercontrols. It's been working
wonderfull up till a few weeks ago, and really crashed yesterday.
Suddenly I can no longer add some of my usercontrols to any of the others
(I've also tried to create new usercontrols and windowforms and add them to
the new control, but that doesn't work any better). It's really frustrating
since I've been able to add them and run the program before.
To debug I've put some messageboxes in my constructors of the uc beeing
added, and it seems to go just fine, so now I'm wondering where the
errormessage comes from. The error being "Object reference not set to an
instance of an object".
The only variable holding an object in the usercontrol is a variable that
holds a reference to another usercontrol, but that is instanciated in
runtime, and is only declared in the header. I've tried to assign it a new
instance, but it doesn't change the outcome and the error still appears. I
have a few variables that have get-set-methods in the usercontrol to be able
to set unique ID-numbers in designtime on the usercontrol thery're placed,
but they're one of system definied types (string, bool and int).
I've been searching the web for others with this problem but unfortunaly
only find people who's forgotten the = new object declaration. So to
summarize:
1. I try to drag a usercontrol (ucChild) on to another usercontrol (ucParent)
2. It goes through the ucChilds constructor without a problem
3. Just as ucParent is about to show the ucChild something happens and I get
to see: "An exception occurred while trying to create an instance of
myUserControl. The exception was 'Object reference not set to an instance of
an object.'". (I can see the ucChild-size show up in the ucParent and
dissappear just before the error message shows up.
So even if the error message says it has to do with my ucChild, I'm starting
to think that it's on the ucParents rePaint (or somewhere else) it just goes
wrong. Any ideas, anyone?
/Emma