473,545 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding @Assembly references programmaticall y

Hi,

Is there any way to add the @Assembly reference to the aspx files
programmaticall y from inside a custom control (when it gets dropped on to
the page from the toolbox)?

I have a custom control - MyControl that implements an interface in another
custom assembly - InterfaceAssemb ly. When MyControl gets dropped on to the
page and run, it results in a "InterfaceAssem bly not found" exception. I am
aware that this can be fixed by manually adding a @Assembly directive
refering to the InterfaceAssemb ly in the GAC (or add a reference to it in
the web.config/machine.config, etc) - but that is not good enough. The
MyControl is a control that will be distributed to a whole lot of people and
we do not want them to do this manual step every time they drag and drop
this control to a page - not very elegant.

I see that Steven Cheng from MS has responded to some related issues in the
newsgroups. Hope to hear from him or someone else from MS.

Thanks in advance,
Praveen
Nov 19 '05 #1
18 3760
If it's a user control, then you can add the @Assembly directive to the ASCX
file. If it's a custom control, then add the reference to the assembly via
project references and then compiling your project. If it's in the App_Code
directory, then add an assembly reference via web.config:

http://msdn.microsoft.com/library/de...asp?frame=true

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

Is there any way to add the @Assembly reference to the aspx files
programmaticall y from inside a custom control (when it gets dropped on
to the page from the toolbox)?

I have a custom control - MyControl that implements an interface in
another custom assembly - InterfaceAssemb ly. When MyControl gets
dropped on to the page and run, it results in a "InterfaceAssem bly not
found" exception. I am aware that this can be fixed by manually adding
a @Assembly directive refering to the InterfaceAssemb ly in the GAC (or
add a reference to it in the web.config/machine.config, etc) - but
that is not good enough. The MyControl is a control that will be
distributed to a whole lot of people and we do not want them to do
this manual step every time they drag and drop this control to a page
- not very elegant.

I see that Steven Cheng from MS has responded to some related issues
in the newsgroups. Hope to hear from him or someone else from MS.

Thanks in advance,
Praveen


Nov 19 '05 #2
If it's a user control, then you can add the @Assembly directive to the ASCX
file. If it's a custom control, then add the reference to the assembly via
project references and then compiling your project. If it's in the App_Code
directory, then add an assembly reference via web.config:

http://msdn.microsoft.com/library/de...asp?frame=true

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

Is there any way to add the @Assembly reference to the aspx files
programmaticall y from inside a custom control (when it gets dropped on
to the page from the toolbox)?

I have a custom control - MyControl that implements an interface in
another custom assembly - InterfaceAssemb ly. When MyControl gets
dropped on to the page and run, it results in a "InterfaceAssem bly not
found" exception. I am aware that this can be fixed by manually adding
a @Assembly directive refering to the InterfaceAssemb ly in the GAC (or
add a reference to it in the web.config/machine.config, etc) - but
that is not good enough. The MyControl is a control that will be
distributed to a whole lot of people and we do not want them to do
this manual step every time they drag and drop this control to a page
- not very elegant.

I see that Steven Cheng from MS has responded to some related issues
in the newsgroups. Hope to hear from him or someone else from MS.

Thanks in advance,
Praveen


Nov 19 '05 #3
Brock,

Thanks for the reply. But, like I mentioned I do not want to add the
reference manually, I want my custom control to INSERT this AUTOMATICALLY
into the aspx file in which it was added, if possible.

Thanks
-Praveen
Nov 19 '05 #4
Brock,

Thanks for the reply. But, like I mentioned I do not want to add the
reference manually, I want my custom control to INSERT this AUTOMATICALLY
into the aspx file in which it was added, if possible.

Thanks
-Praveen
Nov 19 '05 #5
Thanks for Brock's inputs.

Hi Praveen,

From the description of your problem, it is a VS.NET's design-time issue
which I've met in some former issues. And is the following issue the one
you found on the web search ?

#Adding namespaces to code behind automatically (C#)
http://groups.google.com.sg/groups?h...2752%40cpmsftn
gxa06.phx.gbl&r num=2

I think that's exactly the same problem as yours. When we developing a
custom control and use VS.NET's ToolBox to drag it onto our page or
winform. The VS.NET ide will automatcally add assembly reference of the
control's Main Assembly(dll). However, if the control still have other
assembly dependecy, VS.NET won't add them into references automatically.
Then, if we didn't manually add them (in our project) or in our control's
design-time code, there will occur assembly not found exception at runtime.
That's just what you 've encountered, yes?

Also, have you tried the sample code in the above thread?

=============== =====
protected override IComponent[] CreateComponent sCore(IDesigner Host host)
{

ITypeResolution Service service1;
Assembly assembly1,assem bly2;

IComponent component1;
IComponent[] componentArray1 ;

IContainer container1 = host.Container;
service1 = ((ITypeResoluti onService)
host.GetService (typeof(ITypeRe solutionService )));

assembly1 = typeof(ClassLib .UserName).Modu le.Assembly;
assembly2 = typeof(Componen tLib.SimpleComp onent).Module.A ssembly;
service1.Refere nceAssembly(ass embly1.GetName( ));
service1.Refere nceAssembly(ass embly2.GetName( ));

component1 = new ComponentLib.Si mpleComponent() ;
container1.Add( component1);
componentArray1 = new IComponent[]{component1};

return componentArray1 ;

}
=============== ===

We can override the CreateComponent s method of the ToolboxItem and manually
add the necessary assembly dependecy in it. The following two statements
are just the adding reference code:

service1.Refere nceAssembly(ass embly1.GetName( ));
service1.Refere nceAssembly(ass embly2.GetName( ));

Please have a look to see whether it helps. Thanks,
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #6
Thanks for Brock's inputs.

Hi Praveen,

From the description of your problem, it is a VS.NET's design-time issue
which I've met in some former issues. And is the following issue the one
you found on the web search ?

#Adding namespaces to code behind automatically (C#)
http://groups.google.com.sg/groups?h...2752%40cpmsftn
gxa06.phx.gbl&r num=2

I think that's exactly the same problem as yours. When we developing a
custom control and use VS.NET's ToolBox to drag it onto our page or
winform. The VS.NET ide will automatcally add assembly reference of the
control's Main Assembly(dll). However, if the control still have other
assembly dependecy, VS.NET won't add them into references automatically.
Then, if we didn't manually add them (in our project) or in our control's
design-time code, there will occur assembly not found exception at runtime.
That's just what you 've encountered, yes?

Also, have you tried the sample code in the above thread?

=============== =====
protected override IComponent[] CreateComponent sCore(IDesigner Host host)
{

ITypeResolution Service service1;
Assembly assembly1,assem bly2;

IComponent component1;
IComponent[] componentArray1 ;

IContainer container1 = host.Container;
service1 = ((ITypeResoluti onService)
host.GetService (typeof(ITypeRe solutionService )));

assembly1 = typeof(ClassLib .UserName).Modu le.Assembly;
assembly2 = typeof(Componen tLib.SimpleComp onent).Module.A ssembly;
service1.Refere nceAssembly(ass embly1.GetName( ));
service1.Refere nceAssembly(ass embly2.GetName( ));

component1 = new ComponentLib.Si mpleComponent() ;
container1.Add( component1);
componentArray1 = new IComponent[]{component1};

return componentArray1 ;

}
=============== ===

We can override the CreateComponent s method of the ToolboxItem and manually
add the necessary assembly dependecy in it. The following two statements
are just the adding reference code:

service1.Refere nceAssembly(ass embly1.GetName( ));
service1.Refere nceAssembly(ass embly2.GetName( ));

Please have a look to see whether it helps. Thanks,
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #7
Hi Praveen,

After some further checking , I'm thinking the problem is likely
environment specific or project specific. Based on my local test, (a
control with another dependency), I didn't get the assembly not load error.
I've tested using strong-named or not strong-named control assembly. As I
also mentioned in another thread, if possible, you can generate a
simplified version of your problem control and let me do some tests on my
local side.

Looking forward to your response. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 19 '05 #8
Hi Praveen,

After some further checking , I'm thinking the problem is likely
environment specific or project specific. Based on my local test, (a
control with another dependency), I didn't get the assembly not load error.
I've tested using strong-named or not strong-named control assembly. As I
also mentioned in another thread, if possible, you can generate a
simplified version of your problem control and let me do some tests on my
local side.

Looking forward to your response. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 19 '05 #9
Steven,

Glad to hear from you!

Yes, the thread you posted in the other message is what I had referred to.
The other message I posted is also, as you might have figured, related to
resolving this issue.

Before I generate a sample for you, could you please test the following. My
custom control implements an interface defined in this other assembly -
which is what is causing the runtime dll not found error. Does your test
case do something similar (implementing an interface)? If not, please try
that quickly.

Now, if you can reproduce the above issue, then does providing a custom
ToolBoxItem resolve the issue (by forcing a @assembly reference into the
aspx page)?

I will send a sample if you cannot reproduce the above.

Thanks
Praveen

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:6t******** ******@TK2MSFTN GXA02.phx.gbl.. .
Hi Praveen,

After some further checking , I'm thinking the problem is likely
environment specific or project specific. Based on my local test, (a
control with another dependency), I didn't get the assembly not load
error.
I've tested using strong-named or not strong-named control assembly. As I
also mentioned in another thread, if possible, you can generate a
simplified version of your problem control and let me do some tests on my
local side.

Looking forward to your response. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14862
by: V. Srinivas | last post by:
Hi, I tried to install my strong named assembly to GAC. But I get the following error message - 1. If I drag and drop the assembly to GAC using windows explorer --------------------------- The check of the signature failed for assembly 'MyUtils.dll'. --------------------------- OK ---------------------------
1
1702
by: Chuck Bowling | last post by:
Right now I'm trying to get a little deeper into C# and I'm exploring MSIL. I previously installed VS 2002. Later I uninstalled and upgraded to VS 2003. Now, in exploring my \Windows\assembly directory I notice that I have several assembly references that are identical. Same Version, same public key. My question is how do these references...
0
288
by: Praveen Ramesh | last post by:
Hi, Is there any way to add the @Assembly reference to the aspx files programmatically from inside a custom control (when it gets dropped on to the page from the toolbox)? I have a custom control - MyControl that implements an interface in another custom assembly - InterfaceAssembly. When MyControl gets dropped on to the page and run, it...
2
2299
by: Brad | last post by:
I have one of those seemingly simple questions that evades/confuses me. I've created an assembly with bass classes (classes meant to be inherited in other assemblys). In a secondary assembly (my business layer) I created a class which inherits from a base class in the first assembly....so far so good. If I create a third assembly (my UI...
11
1791
by: Juande | last post by:
Hello, My application needs load some dll's at runtime, Is there any way to do it?, can you show me a working example code? Many thanks
3
1478
by: User1013 | last post by:
What is the recommended method of referencing libraries in Visual Studio 2005. Project references or Assembly references?
2
1463
AHayes
by: AHayes | last post by:
This is actually my first post, so please forgive any forum "no-nos" in this post. _The Background For a work project, I need to port an ASP.Net (C#) search application to a SharePoint webpart. To do this "easily" we're using this SharePoint plugin called Smartpart which basically will allow me to use my pre-existing ASP.Net website code...
2
2336
by: chris fellows | last post by:
Can someone tell me if .NET 2.0 framework has a namespace to enable project references to be changed programmatically? My C# project files are stored in source control with DLL references but I want to be create a utility that changes the DLL references to project references in the project file. This is so that all of the projects can be run...
0
1237
by: Simon429 | last post by:
Hi, I got this really annoying problem. When I add a crystal report viewer into my asp.net Form, it automatically added duplicate assembly in my web.config as follows: <add assembly="CrystalDecisions.Web, Version=11.5.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> <add assembly="CrystalDecisions.Web, Version=11.5.3700.0,
0
7478
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...
0
7668
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5343
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...
0
4960
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...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
722
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...

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.