By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,202 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,202 IT Pros & Developers. It's quick & easy.

Problems with user control and class library. This must be a bug I suppose.

P: n/a
Hello!

This is a rather long mail but it's a very interesting one.
I hope you read it. I have tried several times to get an answer to this mail
but I have
not get any answer saying something like this is a bug or that .NET doesn't
support what I
trying to do.
I hope that one that is is microsoft certified read this because this must
be a bug.

I use VS 2003 and C#.

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.

I have successfully managed to build both the user control dll and the class
library dll.
In the user control dll I have a class called B.

Note that I have only problem in design mode so far.
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 in the form is automatically added
see ** below. As you can see
the constructor for class B in the user control is called and here we
instansiate an object of
class C which exist in the class library dll. 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 C in the class library
c.foo();
}
I have a project reference to the class library from the user control.
I also have a project reference to the user control and to the class library
from my project that
build the exe file. In this project I have the form where the user control
is dragged into.

I can build the exe file but my problem is in design mode when the user
control is dragged into a form.

My user control is dependent of class library which mean if I rebuild the
user control
then will the class library also be rebuilt.

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.

As far as I know I have all the references correct set because it works if I
rebuild the user control.
So when I have this error I can solve this error by recompileng the user
control again which rebuild both dll and then it works again when I drag the
user control into a form.

If I do the following my user control will disappear.
1.Rebuild the user control wich rebuild both dll.
2.Drag the user control B into a form.
3.Now rebuild only the class library.
4.Use View designer to look at the user control in the form.
When you do this it will disappear. It will disappear because it can't
find the class library dll for some reason.
Another thing I can't use the workaround that means rebuild the user control
because
that would be a very bad solution. If I can't use it in the way I do now I
must do some change in the design.

One more thing is that if I add some method in the class library and then
rebuild this one
I can see all the added method in "View in object browser" when right
clicking on the last in the references.

I just want to say it's very easy to reproduce my problem and see by
yourself that it's a strange problem.

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

//Tony

Apr 4 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Something aikin to this, mabye?

http://support.microsoft.com/default...=rss&spid=3040

This one might help to further diagnose the problem:

http://groups.google.it/group/micros...caee654e0e6e2d

Laura

"tony" <jo*****************@telia.com> ha scritto nel messaggio
news:uz**************@TK2MSFTNGP12.phx.gbl...
Hello!

This is a rather long mail but it's a very interesting one.
I hope you read it. I have tried several times to get an answer to this
mail
but I have
not get any answer saying something like this is a bug or that .NET
doesn't
support what I
trying to do.
I hope that one that is is microsoft certified read this because this must
be a bug.

I use VS 2003 and C#.

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.

I have successfully managed to build both the user control dll and the
class
library dll.
In the user control dll I have a class called B.

Note that I have only problem in design mode so far.
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 in the form is automatically added
see ** below. As you can see
the constructor for class B in the user control is called and here we
instansiate an object of
class C which exist in the class library dll. 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 C in the class library
c.foo();
}
I have a project reference to the class library from the user control.
I also have a project reference to the user control and to the class
library
from my project that
build the exe file. In this project I have the form where the user control
is dragged into.

I can build the exe file but my problem is in design mode when the user
control is dragged into a form.

My user control is dependent of class library which mean if I rebuild the
user control
then will the class library also be rebuilt.

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.

As far as I know I have all the references correct set because it works if
I
rebuild the user control.
So when I have this error I can solve this error by recompileng the user
control again which rebuild both dll and then it works again when I drag
the
user control into a form.

If I do the following my user control will disappear.
1.Rebuild the user control wich rebuild both dll.
2.Drag the user control B into a form.
3.Now rebuild only the class library.
4.Use View designer to look at the user control in the form.
When you do this it will disappear. It will disappear because it can't
find the class library dll for some reason.
Another thing I can't use the workaround that means rebuild the user
control
because
that would be a very bad solution. If I can't use it in the way I do now I
must do some change in the design.

One more thing is that if I add some method in the class library and then
rebuild this one
I can see all the added method in "View in object browser" when right
clicking on the last in the references.

I just want to say it's very easy to reproduce my problem and see by
yourself that it's a strange problem.

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

//Tony

Apr 4 '06 #2

P: n/a
I tried your example, and occured the same errors. Still I found a solution.
If in AssemblyInfo.cs file in Library and UserControl project you put a non
variable version value, the error isn't appear.

Try to modify

[assembly: AssemblyVersion("1.0.*")]

to

[assembly: AssemblyVersion("1.0.1")]

Mihaly

"tony" wrote:
Hello!

This is a rather long mail but it's a very interesting one.
I hope you read it. I have tried several times to get an answer to this mail
but I have
not get any answer saying something like this is a bug or that .NET doesn't
support what I
trying to do.
I hope that one that is is microsoft certified read this because this must
be a bug.

I use VS 2003 and C#.

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.

I have successfully managed to build both the user control dll and the class
library dll.
In the user control dll I have a class called B.

Note that I have only problem in design mode so far.
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 in the form is automatically added
see ** below. As you can see
the constructor for class B in the user control is called and here we
instansiate an object of
class C which exist in the class library dll. 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 C in the class library
c.foo();
}
I have a project reference to the class library from the user control.
I also have a project reference to the user control and to the class library
from my project that
build the exe file. In this project I have the form where the user control
is dragged into.

I can build the exe file but my problem is in design mode when the user
control is dragged into a form.

My user control is dependent of class library which mean if I rebuild the
user control
then will the class library also be rebuilt.

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.

As far as I know I have all the references correct set because it works if I
rebuild the user control.
So when I have this error I can solve this error by recompileng the user
control again which rebuild both dll and then it works again when I drag the
user control into a form.

If I do the following my user control will disappear.
1.Rebuild the user control wich rebuild both dll.
2.Drag the user control B into a form.
3.Now rebuild only the class library.
4.Use View designer to look at the user control in the form.
When you do this it will disappear. It will disappear because it can't
find the class library dll for some reason.
Another thing I can't use the workaround that means rebuild the user control
because
that would be a very bad solution. If I can't use it in the way I do now I
must do some change in the design.

One more thing is that if I add some method in the class library and then
rebuild this one
I can see all the added method in "View in object browser" when right
clicking on the last in the references.

I just want to say it's very easy to reproduce my problem and see by
yourself that it's a strange problem.

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

//Tony

Apr 4 '06 #3

P: n/a
Hello!!
Hello!!

I get the same problem even if I change in AssemblyInfo.cs in the way you
suggested.
You must have done something more to have it work.
//Tony
"Mihaly" <Mi****@discussions.microsoft.com> skrev i meddelandet
news:C6**********************************@microsof t.com...
I tried your example, and occured the same errors. Still I found a solution. If in AssemblyInfo.cs file in Library and UserControl project you put a non variable version value, the error isn't appear.

Try to modify

[assembly: AssemblyVersion("1.0.*")]

to

[assembly: AssemblyVersion("1.0.1")]

Mihaly

"tony" wrote:
Hello!

This is a rather long mail but it's a very interesting one.
I hope you read it. I have tried several times to get an answer to this mail but I have
not get any answer saying something like this is a bug or that .NET doesn't support what I
trying to do.
I hope that one that is is microsoft certified read this because this must be a bug.

I use VS 2003 and C#.

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.

I have successfully managed to build both the user control dll and the class library dll.
In the user control dll I have a class called B.

Note that I have only problem in design mode so far.
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 in the form is automatically added see ** below. As you can see
the constructor for class B in the user control is called and here we
instansiate an object of
class C which exist in the class library dll. 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 C in the class library c.foo();
}
I have a project reference to the class library from the user control.
I also have a project reference to the user control and to the class library from my project that
build the exe file. In this project I have the form where the user control is dragged into.

I can build the exe file but my problem is in design mode when the user
control is dragged into a form.

My user control is dependent of class library which mean if I rebuild the user control
then will the class library also be rebuilt.

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.

As far as I know I have all the references correct set because it works if I rebuild the user control.
So when I have this error I can solve this error by recompileng the user
control again which rebuild both dll and then it works again when I drag the user control into a form.

If I do the following my user control will disappear.
1.Rebuild the user control wich rebuild both dll.
2.Drag the user control B into a form.
3.Now rebuild only the class library.
4.Use View designer to look at the user control in the form.
When you do this it will disappear. It will disappear because it can't
find the class library dll for some reason.
Another thing I can't use the workaround that means rebuild the user control because
that would be a very bad solution. If I can't use it in the way I do now I must do some change in the design.

One more thing is that if I add some method in the class library and then rebuild this one
I can see all the added method in "View in object browser" when right
clicking on the last in the references.

I just want to say it's very easy to reproduce my problem and see by
yourself that it's a strange problem.

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

//Tony

Apr 4 '06 #4

P: n/a
Are you using project references or referencing the .dll's directly?
It sounds like when you change and recompile class C that it's version
number changes and that the user control was depending on the previous
version. That's one reason you should use project references where
possible.

Apr 4 '06 #5

P: n/a
Hello!
My example is working. I changed the version in both AssemblyInfo.cs files
and I added my UserControl to My UserControls toolbar with rigth click,
add/remove items, browse my UserControl.dll and select may control's checkbox.

I hope this help you.

Mihaly
"tony" wrote:
Hello!!
Hello!!

I get the same problem even if I change in AssemblyInfo.cs in the way you
suggested.
You must have done something more to have it work.
//Tony
"Mihaly" <Mi****@discussions.microsoft.com> skrev i meddelandet
news:C6**********************************@microsof t.com...
I tried your example, and occured the same errors. Still I found a

solution.
If in AssemblyInfo.cs file in Library and UserControl project you put a

non
variable version value, the error isn't appear.

Try to modify

[assembly: AssemblyVersion("1.0.*")]

to

[assembly: AssemblyVersion("1.0.1")]

Mihaly

"tony" wrote:
Hello!

This is a rather long mail but it's a very interesting one.
I hope you read it. I have tried several times to get an answer to this mail but I have
not get any answer saying something like this is a bug or that .NET doesn't support what I
trying to do.
I hope that one that is is microsoft certified read this because this must be a bug.

I use VS 2003 and C#.

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.

I have successfully managed to build both the user control dll and the class library dll.
In the user control dll I have a class called B.

Note that I have only problem in design mode so far.
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 in the form is automatically added see ** below. As you can see
the constructor for class B in the user control is called and here we
instansiate an object of
class C which exist in the class library dll. 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 C in the class library c.foo();
}
I have a project reference to the class library from the user control.
I also have a project reference to the user control and to the class library from my project that
build the exe file. In this project I have the form where the user control is dragged into.

I can build the exe file but my problem is in design mode when the user
control is dragged into a form.

My user control is dependent of class library which mean if I rebuild the user control
then will the class library also be rebuilt.

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.

As far as I know I have all the references correct set because it works if I rebuild the user control.
So when I have this error I can solve this error by recompileng the user
control again which rebuild both dll and then it works again when I drag the user control into a form.

If I do the following my user control will disappear.
1.Rebuild the user control wich rebuild both dll.
2.Drag the user control B into a form.
3.Now rebuild only the class library.
4.Use View designer to look at the user control in the form.
When you do this it will disappear. It will disappear because it can't
find the class library dll for some reason.
Another thing I can't use the workaround that means rebuild the user control because
that would be a very bad solution. If I can't use it in the way I do now I must do some change in the design.

One more thing is that if I add some method in the class library and then rebuild this one
I can see all the added method in "View in object browser" when right
clicking on the last in the references.

I just want to say it's very easy to reproduce my problem and see by
yourself that it's a strange problem.

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

//Tony


Apr 6 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.