PC Review


Reply
Thread Tools Rate Thread

Adding usercontrols to other usercontrols

 
 
=?Utf-8?B?RW1tYQ==?=
Guest
Posts: n/a
 
      27th Oct 2004
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
 
Reply With Quote
 
 
 
 
Stoitcho Goutsev \(100\) [C# MVP]
Guest
Posts: n/a
 
      27th Oct 2004
Hi Emma,

The best would be if could post some working sample that demonstrates the
problem. I understand that your project could be rather big to post it in a
ng, but at least you can post the stack trace of the exception.
Or if you want to you can send me some part of the project that demonstrates
the problem at guzzev(at)yahoo(dot)com.

BTW if it happens (as I understant it is) at design time you can debug

You can start a new instance of VS.
Open the project in this instace.( now you have the project open twise)
In one of the insances go to 'Debug' menu and click on "Processes..." in the
dialog attach the debuger to the other VS
You can set exception settings to stop on all exceptions. You can set some
breakpoints as well. In the second VS add the user control to the parent and
so on.

This can be done via the projects setting but as long as you don't write
designers this method of debugging is better for your needs, I believe

--
HTH
Stoitcho Goutsev (100) [C# MVP]


"Emma" <(E-Mail Removed)> wrote in message
news:F82AA5EE-E483-47F4-8E0C-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?RW1tYQ==?=
Guest
Posts: n/a
 
      27th Oct 2004
Hi Goutsev,

Thank you for a quick reply. Unfortunately the project is rather extensive,
with four projects and a lot of references to our own dll:s.

We're working on breaking out some code at the moment, if the problem still
persists tomorrow when that part should be done, I'll try to make an example
solution with only two - three usercontrols and post it here.

If you come up with some other bright ideas until then - don't hesitate to
tell me.

/Emma

"Stoitcho Goutsev (100) [C# MVP]" wrote:

> Hi Emma,
>
> The best would be if could post some working sample that demonstrates the
> problem. I understand that your project could be rather big to post it in a
> ng, but at least you can post the stack trace of the exception.
> Or if you want to you can send me some part of the project that demonstrates
> the problem at guzzev(at)yahoo(dot)com.
>
> BTW if it happens (as I understant it is) at design time you can debug
>
> You can start a new instance of VS.
> Open the project in this instace.( now you have the project open twise)
> In one of the insances go to 'Debug' menu and click on "Processes..." in the
> dialog attach the debuger to the other VS
> You can set exception settings to stop on all exceptions. You can set some
> breakpoints as well. In the second VS add the user control to the parent and
> so on.
>
> This can be done via the projects setting but as long as you don't write
> designers this method of debugging is better for your needs, I believe
>
> --
> HTH
> Stoitcho Goutsev (100) [C# MVP]
>
>
> "Emma" <(E-Mail Removed)> wrote in message
> news:F82AA5EE-E483-47F4-8E0C-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserControls hula Microsoft C# .NET 3 23rd Nov 2006 01:30 PM
UserControls Kim Microsoft C# .NET 1 25th May 2005 05:56 PM
usercontrols gokri Microsoft ADO .NET 0 18th Dec 2004 12:17 PM
Dynamically adding usercontrols =?Utf-8?B?QWxhbiBMYW1iZXJ0?= Microsoft ASP .NET 1 27th Sep 2004 01:16 AM
Problem with adding UserControls programtic in the OnPreRender event and still keep the UC viewState Flare Microsoft ASP .NET 5 21st Nov 2003 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:55 AM.