Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 11-03-2009, 10:41 AM   #1 (permalink)
In The Zone
 
Pragadheesh's Avatar
 
Join Date: Jul 2006
Location: Coimbatore
Posts: 403
Unhappy C# doubt adding references at run time


hi,

how can i add an assembly(dll) as reference in a C# project at run time.?! i need to add a reference at run time.!?


Consider i ave a class library(dll) in "C:\Documents and Settings\Pragadheesh\My Documents\Visual Studio 2005\Projects\qwerty\qwerty\bin\Debug\qwerty.dll"

i need to add this dll as reference in my project. how can i do this at run time.?
Pragadheesh is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 13-03-2009, 12:09 PM   #2 (permalink)
Canon 1000D
 
astroutkarsh's Avatar
 
Join Date: Apr 2007
Location: Pune
Posts: 80
Lightbulb Re: C# doubt adding references at run time

Sample Code Snippet

System.Reflection.Assembly extAssembly;
Object objExtAssembly;
Type tpExtAssembly;

extAssembly = System.Reflection.Assembly.LoadFile(AppRelativeVir tualPath.ToString () + "\\<AssemblyFileName>.dll");
tpExtAssembly = extAssembly.GetType("<Assembly>.<yourClass>");
objExtAssembly = Activator.CreateInstance(tpExtAssembly);

Ref Links
1. http://msdn.microsoft.com/en-us/library/25y1ya39.aspx
2. http://social.microsoft.com/Forums/e...b-6fad5bdeec6a
__________________
Canon 1000D + 18-55 + 50mm f/1.8 + 55-250 IS :-)
astroutkarsh is offline  
Old 16-03-2009, 01:06 PM   #3 (permalink)
In The Zone
 
Pragadheesh's Avatar
 
Join Date: Jul 2006
Location: Coimbatore
Posts: 403
Question Re: C# doubt adding references at run time

i got the answer. here it is.

Assembly asm = Assembly.LoadFile(@"assembly_path");
Type type = asm.GetType("assembly.class", false, true);

using this we can add references at run time.
Pragadheesh is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Sujeet
- by gforz
- by soumya
- by icebags

Advertisement




All times are GMT +5.5. The time now is 03:09 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2