|
-
July 5th, 2005, 01:36 PM
#1
Adding User Control
Hi,
I am trying to add my user control into the toolbox then onto my form. Every time I try it tells me it cannot create an instance of the control, one of the controls dependancies could not be found.
Any ideas?
-
July 5th, 2005, 02:35 PM
#2
Re: Adding User Control
what kind of a user control is it?is it a web user control(ascx) or a windows user control?
-
July 5th, 2005, 02:41 PM
#3
Re: Adding User Control
It is a Windows control...it basically says a library I reference inside the control isn't compiled or something, but it is fine...
-
July 6th, 2005, 12:34 AM
#4
Re: Adding User Control
The Toolbox is somewhat weak in VS.NET 2003.
This thing can happen because of many reasons: run-time bug in the constuctor of the user control, reference that is not in the correct location, and so on.
I suggest to do the following steps:
1. Add the reference to the library with control ourself.
2. Add the control by code (not from the designer):
Code:
YourUserControl uc = new YourUserControl();
3. put a breakpoint on that line of code. Step into the constructor of the control and try to find bugs.
-
July 6th, 2005, 07:08 AM
#5
Re: Adding User Control
Well that is the weird thing...I added the control by hand previously after I got this error and I haven't found any bugs yet...
-
July 6th, 2005, 07:20 AM
#6
Re: Adding User Control
Well before using the user control there are few things which you should take care of..
1. If you are developing the User Control in the same project, then before using it you need to build the project first.
2. If you have the user control in the separate project, make sure that you have added the reference to that assembly prior to using it.
3. There is no need to add a user control to the Toolbox, it will automatically be added under My User Controls tab once you build your project.
4. If you do any change in the source of your user control, make sure you re-build the porject and then use a new instance of the user_control..
HTH
-
July 6th, 2005, 07:28 AM
#7
Re: Adding User Control
Yes I have the control in the same project as the form I am dropping it on.
I build the project before the attempt - but my user controls are never added automatically to the 'My User Controls' part of the toolbox??
All the references are fine I am positive of that - I add other user controls just fine the same way but this one won't let me do it. I can add it programmatically and use it but then if I make a change to the form it disappears on me.
-
July 6th, 2005, 07:43 AM
#8
Re: Adding User Control
I got the control added...the suggestion about cleaning up the constructor helped...thanks for all your suggestions!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|