problems when using user control and class library

T

Tony Johansson

Hello!!

I use VS 2003 and C#.
I have sent several mail even tried with crossgroup because I want to find
out if my problem
is a bug in .NET or if .NET doesn't support what I do. It's only one of
these left I suppose.

I use project reference where a need to.

I have three project in my solution. One that build the exe and one that
build the user control dll and one that build the class library dll.

Note that I have only problem in design mode.
Look here. This is what I do and what should happen.
I drag the user control icon named B from the Toolbox into a form and when I
do so a row in the InitializeComponent is added see ** below. As you can see
the constructor for class B is used and here we instansiate an object of
class C which exist in the class library. This means that when we drag the
user control from the toolbox we use the class library to instansiate class
C.

private void InitializeComponent()
{
this.b1= new B();// **
}

Here we have the constructor for class B for the user control.
public B()
{
InitializeComponent();
C c = new C(); //Here we instansiate a class in the class library
c.foo();
}

If I recompile the user control which build both dll everything works fine
when I drag the user control into a form.
If I instead only rebuild the class library and then try to drag the user
control into a form I get this error
"An exception occured while trying to create an instance of
B. The execption was "?"."
This is because the class library can't be found.

So when I have this error I can solve this error by recompileng the user
control again and then it works again.

Has anybody any suggestion about my problem.
Is it a bug or .NET might not fully support what I do.

//Tony
 
V

Vijay

Tony I have had this problem intermittently.. were the usercontrol will
disappear for some reason if it can't find the depend dlls, but If I compile
the entire UC project and then my main project all will work fine... I
suggest that you add both projects in the same solution space and then have
reference going , so the UC control builds and then the exe builds... , that
seems to do it.. I know it is sort of pain, but I have not received much
help on this either.... Let me know if you get any other trick to work, I
will be very interested in learning.!

VJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top