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

Why is it not possible to call a class library method from a user control.

P: n/a
Hello!

I have one solution file that consist of three project.
One project that build the exe file called A
One project that build a user control dll. Here we have a class called B
One project that build a class library dll. Here we have a class called C

We have one dependency and that is from the user control to the class
library because
in the constructor for class B in the user control we have a call to
instansiate class C in the class library dll.
public B()
{
InitializeComponent();
Last.C last = new Last.C();
last.foo();
}

In the project that create the exe file I have a project reference to the
user control.
In the project that create the user control I have a project reference to
the class library.

When I add the user control to the Toolbox I use the obj/debug directory to
select the user control dll.

Now to my problem when I try to drag the user control from the toolbox into
a form I get the following error "An exception occured while trying to
create an instance of WindowsControlLibrary.B. The execption was "?"."

Is this kind of a bug that cause this problem.
Is it possible to solve this kind of problem in some way.
I have even rebuild the user control dll and the class library dll but it
doesn't matter.
//Tony



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


P: n/a
Technically this should work... I suggest manually copying the library dll
to the debug directory of the executable and trying.. or making sure that in
the project reference paths that you have the directory in which you can
find the library dll

VJ

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:A8*******************@newsb.telia.net...
Hello!

I have one solution file that consist of three project.
One project that build the exe file called A
One project that build a user control dll. Here we have a class called B
One project that build a class library dll. Here we have a class called C

We have one dependency and that is from the user control to the class
library because
in the constructor for class B in the user control we have a call to
instansiate class C in the class library dll.
public B()
{
InitializeComponent();
Last.C last = new Last.C();
last.foo();
}

In the project that create the exe file I have a project reference to the
user control.
In the project that create the user control I have a project reference to
the class library.

When I add the user control to the Toolbox I use the obj/debug directory
to
select the user control dll.

Now to my problem when I try to drag the user control from the toolbox
into
a form I get the following error "An exception occured while trying to
create an instance of WindowsControlLibrary.B. The execption was "?"."

Is this kind of a bug that cause this problem.
Is it possible to solve this kind of problem in some way.
I have even rebuild the user control dll and the class library dll but it
doesn't matter.
//Tony


Apr 2 '06 #2

P: n/a
Hello!!

When this control library is trying to access a method in the class
library where is the search path that is used.

//Tony
"Vijay" <vi***@msdiscussions.com> skrev i meddelandet
news:%2****************@TK2MSFTNGP12.phx.gbl...
Technically this should work... I suggest manually copying the library dll to the debug directory of the executable and trying.. or making sure that in the project reference paths that you have the directory in which you can
find the library dll

VJ

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:A8*******************@newsb.telia.net...
Hello!

I have one solution file that consist of three project.
One project that build the exe file called A
One project that build a user control dll. Here we have a class called B One project that build a class library dll. Here we have a class called C
We have one dependency and that is from the user control to the class
library because
in the constructor for class B in the user control we have a call to
instansiate class C in the class library dll.
public B()
{
InitializeComponent();
Last.C last = new Last.C();
last.foo();
}

In the project that create the exe file I have a project reference to the user control.
In the project that create the user control I have a project reference to the class library.

When I add the user control to the Toolbox I use the obj/debug directory to
select the user control dll.

Now to my problem when I try to drag the user control from the toolbox
into
a form I get the following error "An exception occured while trying to
create an instance of WindowsControlLibrary.B. The execption was "?"."

Is this kind of a bug that cause this problem.
Is it possible to solve this kind of problem in some way.
I have even rebuild the user control dll and the class library dll but it doesn't matter.
//Tony





Apr 2 '06 #3

P: n/a
Its defined in the framework, so at run time it will look for in App.Config
is specified any... default search is executable location, the GAC..and so
on.. You can override to make it look at a specific location in App.Config..
I don't remember the exact syntax of it right now.. but if you Google it,
you will get examples.. one other place is codeproject.com to see for
samples..

VJ

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:_S*******************@newsb.telia.net...
Hello!!

When this control library is trying to access a method in the class
library where is the search path that is used.

//Tony
"Vijay" <vi***@msdiscussions.com> skrev i meddelandet
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Technically this should work... I suggest manually copying the library

dll
> to the debug directory of the executable and trying.. or making sure

that in
> the project reference paths that you have the directory in which you

can
> find the library dll
>
> VJ
>
> "Tony Johansson" <jo*****************@telia.com> wrote in message
> news:A8*******************@newsb.telia.net...
>> Hello!
>>
>> I have one solution file that consist of three project.
>> One project that build the exe file called A
>> One project that build a user control dll. Here we have a class called B >> One project that build a class library dll. Here we have a class called C >>
>> We have one dependency and that is from the user control to the class
>> library because
>> in the constructor for class B in the user control we have a call to
>> instansiate class C in the class library dll.
>> public B()
>> {
>> InitializeComponent();
>> Last.C last = new Last.C();
>> last.foo();
>> }
>>
>> In the project that create the exe file I have a project reference to the >> user control.
>> In the project that create the user control I have a project reference to >> the class library.
>>
>> When I add the user control to the Toolbox I use the obj/debug directory >> to
>> select the user control dll.
>>
>> Now to my problem when I try to drag the user control from the toolbox
>> into
>> a form I get the following error "An exception occured while trying to
>> create an instance of WindowsControlLibrary.B. The execption was "?"."
>>
>> Is this kind of a bug that cause this problem.
>> Is it possible to solve this kind of problem in some way.
>> I have even rebuild the user control dll and the class library dll but it >> doesn't matter.
>>
>>
>> //Tony
>>
>>
>>
>>
>>
>>

>
>


Apr 2 '06 #4

P: n/a
Hello!!

Is the search path different between run time and design time.

I use the term design time when the user control is dragged from the
Toolbox into the form and
runtime when you actually execute the exe file.

Do you know if the problem with path would be easier if I use the GAC.

//Tony

"Vijay" <vi***@msdiscussions.com> skrev i meddelandet
news:uH**************@TK2MSFTNGP11.phx.gbl...
Its defined in the framework, so at run time it will look for in App.Config is specified any... default search is executable location, the GAC..and so on.. You can override to make it look at a specific location in App.Config.. I don't remember the exact syntax of it right now.. but if you Google it, you will get examples.. one other place is codeproject.com to see for
samples..

VJ

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:_S*******************@newsb.telia.net...
Hello!!

When this control library is trying to access a method in the class
library where is the search path that is used.

//Tony
"Vijay" <vi***@msdiscussions.com> skrev i meddelandet
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Technically this should work... I suggest manually copying the library
dll
> to the debug directory of the executable and trying.. or making sure

that in
> the project reference paths that you have the directory in which you

can
> find the library dll
>
> VJ
>
> "Tony Johansson" <jo*****************@telia.com> wrote in message
> news:A8*******************@newsb.telia.net...
>> Hello!
>>
>> I have one solution file that consist of three project.
>> One project that build the exe file called A
>> One project that build a user control dll. Here we have a class
called B
>> One project that build a class library dll. Here we have a class

called C
>>
>> We have one dependency and that is from the user control to the
class >> library because
>> in the constructor for class B in the user control we have a call to >> instansiate class C in the class library dll.
>> public B()
>> {
>> InitializeComponent();
>> Last.C last = new Last.C();
>> last.foo();
>> }
>>
>> In the project that create the exe file I have a project reference to the
>> user control.
>> In the project that create the user control I have a project
reference to
>> the class library.
>>
>> When I add the user control to the Toolbox I use the obj/debug

directory
>> to
>> select the user control dll.
>>
>> Now to my problem when I try to drag the user control from the
toolbox >> into
>> a form I get the following error "An exception occured while trying to >> create an instance of WindowsControlLibrary.B. The execption was "?"." >>
>> Is this kind of a bug that cause this problem.
>> Is it possible to solve this kind of problem in some way.
>> I have even rebuild the user control dll and the class library dll

but it
>> doesn't matter.
>>
>>
>> //Tony
>>
>>
>>
>>
>>
>>
>
>





Apr 2 '06 #5

P: n/a
No it is not.. the only additional path I believe it will search at design
time is any you set in project references.. Otherwise the path search is
same, design time or run-time..

I think that is ok to do, to have in the GAC. But personally I feel the best
practice to keep all deployed assemblies together in the same path or a
relative path as specified in app.config. The only place you should go for
GAC is if you are sharing the assembly with more than say 1 application or
developing something like a control that all .NET developers will use...

HTH
Vijay

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:Ib*******************@newsb.telia.net...
Hello!!

Is the search path different between run time and design time.

I use the term design time when the user control is dragged from the
Toolbox into the form and
runtime when you actually execute the exe file.

Do you know if the problem with path would be easier if I use the GAC.

//Tony

"Vijay" <vi***@msdiscussions.com> skrev i meddelandet
news:uH**************@TK2MSFTNGP11.phx.gbl...
> Its defined in the framework, so at run time it will look for in

App.Config
> is specified any... default search is executable location, the GAC..and

so
> on.. You can override to make it look at a specific location in

App.Config..
> I don't remember the exact syntax of it right now.. but if you Google

it,
> you will get examples.. one other place is codeproject.com to see for
> samples..
>
> VJ
>
> "Tony Johansson" <jo*****************@telia.com> wrote in message
> news:_S*******************@newsb.telia.net...
>> Hello!!
>>
>> When this control library is trying to access a method in the class
>> library where is the search path that is used.
>>
>> //Tony
>>
>>
>> "Vijay" <vi***@msdiscussions.com> skrev i meddelandet
>> news:%2****************@TK2MSFTNGP12.phx.gbl...
>> > Technically this should work... I suggest manually copying the library >> dll
>> > to the debug directory of the executable and trying.. or making sure >> that in
>> > the project reference paths that you have the directory in which you >> can
>> > find the library dll
>> >
>> > VJ
>> >
>> > "Tony Johansson" <jo*****************@telia.com> wrote in message
>> > news:A8*******************@newsb.telia.net...
>> >> Hello!
>> >>
>> >> I have one solution file that consist of three project.
>> >> One project that build the exe file called A
>> >> One project that build a user control dll. Here we have a class called >> B
>> >> One project that build a class library dll. Here we have a class
>> called C
>> >>
>> >> We have one dependency and that is from the user control to the class >> >> library because
>> >> in the constructor for class B in the user control we have a call to >> >> instansiate class C in the class library dll.
>> >> public B()
>> >> {
>> >> InitializeComponent();
>> >> Last.C last = new Last.C();
>> >> last.foo();
>> >> }
>> >>
>> >> In the project that create the exe file I have a project reference to >> the
>> >> user control.
>> >> In the project that create the user control I have a project reference >> to
>> >> the class library.
>> >>
>> >> When I add the user control to the Toolbox I use the obj/debug
>> directory
>> >> to
>> >> select the user control dll.
>> >>
>> >> Now to my problem when I try to drag the user control from the toolbox >> >> into
>> >> a form I get the following error "An exception occured while trying to >> >> create an instance of WindowsControlLibrary.B. The execption was "?"." >> >>
>> >> Is this kind of a bug that cause this problem.
>> >> Is it possible to solve this kind of problem in some way.
>> >> I have even rebuild the user control dll and the class library dll but >> it
>> >> doesn't matter.
>> >>
>> >>
>> >> //Tony
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>>
>>

>
>


Apr 3 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.