473,749 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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()
{
InitializeCompo nent();
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 WindowsControlL ibrary.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 1944
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******** ***********@new sb.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()
{
InitializeCompo nent();
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 WindowsControlL ibrary.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***@msdiscus sions.com> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP12.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******** ***********@new sb.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()
{
InitializeCompo nent();
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 WindowsControlL ibrary.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******** ***********@new sb.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***@msdiscus sions.com> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP12.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******** ***********@new sb.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()
>> {
>> InitializeCompo nent();
>> 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 WindowsControlL ibrary.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***@msdiscus sions.com> skrev i meddelandet
news:uH******** ******@TK2MSFTN GP11.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******** ***********@new sb.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***@msdiscus sions.com> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP12.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******** ***********@new sb.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()
>> {
>> InitializeCompo nent();
>> 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 WindowsControlL ibrary.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******** ***********@new sb.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***@msdiscus sions.com> skrev i meddelandet
news:uH******** ******@TK2MSFTN GP11.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******** ***********@new sb.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***@msdiscus sions.com> skrev i meddelandet
>> news:%2******** ********@TK2MSF TNGP12.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******** ***********@new sb.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()
>> >> {
>> >> InitializeCompo nent();
>> >> 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 WindowsControlL ibrary.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
11878
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 to-be-developed-function cmdOkay_Click() function as described below. 1. Create an user control that contains an OK button as below Public Class MyButton:System.Windows.Form.UserControl
7
2234
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 control is contained regardless of the type currently displayed without having to use a huge switch somthing like: switch(curentUserType.GetType()) { case "Person": ((person)currentUserControl).LoadFromForm();
4
4291
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 I know I need to call a function that will save data but I'm not sure exactly when to call this function. I've tried two ways and both seem to have 'gotcha's':
3
2469
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 = Session("SN") txtScan_TextChanged(sender, e) Session("GRN") = "" Exit Sub End If
5
555
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 it is invoked by pressing "F5", or when the web.config file is modified. In all these cases the web.config file contains <identity impersonate="false" />. The mysterious problem arrises when I set <identity impersonate="true"/> in the...
4
1688
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 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
5
1997
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 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.
1
1639
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 run the app, the method runs just fine. The class library returns the array of objects and the ComboBox is loaded. The problem I am having is when I try to open the form that contains the user control in the designer. Instead of the form, I get...
11
7654
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 characters into the display myself - but that's not the main issue at this time. I've tried a scrolling multiline text box but once the original viewable area fills up and it starts scrolling the flashing of the entire area drives me nuts. The...
0
8997
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.