473,418 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

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

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
5 1920
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
7
by: Byron | last post by:
I have several user controls that have a few methods in common, such LoadFromForm() which populates an object from controls on the form. I want to call that method from the form in which the...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
3
by: Kathy Burke | last post by:
Hi, I'm tired, so this question may be silly. I have a fairly long sub procedure. Based on one condition, I load another sub with the following: If Session("GRN") = "complete" Then txtScan.Text...
5
by: AAguiar | last post by:
I have an asp.net project where the code behind the aspx page calls a c# class which makes calls to a managed static C++ class. The C# class works fine when the asp net worker process starts, when...
4
by: Tony Johansson | last post by:
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...
5
by: tony | last post by:
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...
1
by: Dale | last post by:
I have a user control on a Windows Form that, in its Load event handler, calls a method from a class library to initialize an array of objects that are then used to populate a ComboBox. When I...
11
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.