473,769 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using assemblies in runtime?

Hello..

Just wondering, is it possible to make a folder with assemblies and have the
application to read it in runtime?

Possible use: Could be menues, if the menu assembly exists in the folder
then it's added to the gui !
Reason: licensing
Kind regards
Nov 16 '05 #1
2 1411
Janus... No problem, but there are security risks.

http://www.geocities.com/jeff_louie/OOP/oop13.htm

// now dynamically load class DrawPlugIn.Tria ngle which
// implements interface MyInterface.IDr awable
Assembly assembly= null;
try
{
// tell app where to look for plugins
AppDomain.Curre ntDomain.Append PrivatePath("pl ugins");
// get absolute path to our private assemblies
string path=
AppDomain.Curre ntDomain.BaseDi rectory+"plugin s";

// create plugins folder if one does not exist
DirectoryInfo info= new DirectoryInfo(p ath);
if (!info.Exists){ info.Create();}
// discover all dlls in plugins folder
string[] dir= Directory.GetFi les(path,"*.dll ");
// iterate over files in folder plugins
foreach (string s in dir)
{
string dll= Path.GetFileNam eWithoutExtensi on(s);
assembly= Assembly.Load(d ll); // in folder
plugins
Type[] types= assembly.GetTyp es();
foreach(Type t in types)
{
Console.WriteLi ne("Type: {0}",t);
try
{
// only load if implements
IDrawable
// use fully qualified name!
if
(t.GetInterface ("MyInterface.I Drawable")!= null)
//if
(typeof(IDrawab le).IsAssignabl eFrom(t)) // safer
{
// dynamically load this
class
object obj=
Activator.Creat eInstance(t);
drawableList.Ad d(obj);
// no need to cast
}
}
catch(Exception e)
{
Console.WriteLi ne(e);
}
}
}
}
catch(Exception e)
{
Console.WriteLi ne(e);
}

Regards,
Jeff
Just wondering, is it possible to make a folder with assemblies and

have the
application to read it in runtime?<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #2
It is possible,you can use the static method Load of the Assembly to load the assembly to the AppDomain and use reflection to access the metadata at runtime.
Nov 16 '05 #3

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

Similar topics

12
1961
by: Mark Broadbent | last post by:
Hi guys, just going through remoting at the moment and a couple of questions relating to .net in general has surfaced. Firstly I have seen in the designer that for the namespace and many of its associated classes of System.Runtime.Remoting are available, but certain ones are not. A reference to System.Runtime.Remoting needs to be added to make available all the unavailable ones. Now although I (think) understand the concept that an...
0
1243
by: Paul | last post by:
Snippet from web.config: <startup> <supportedRuntime version="v1.0.3705" /> <requiredRuntime version="v1.0.3705" safemode="true"/> </startup> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft- com:asm.v1" appliesTo="v1.1.4322"> <publisherPolicy apply="no"/>
8
34665
by: Subra Mallampalli | last post by:
Hi, I am trying to use <runtime> section within the web.config file. However, the contents of the <runtime> section seem to be ignored. What am i missing here? Is <runtime> section not used by web apps? Any help is greatly appreciated. Thanks,
2
2725
by: Luis Arvayo | last post by:
Actually it is: How to define the plugin assemblies path in order to find other assemblies which the plugin depends on. Example: If I have: c:\myapp\application.exe
4
1948
by: Tony Johansson | last post by:
Hello! I have read some info on the WWW about GAC It says the following. "If you want to use an assembly from the GAC, you should drop your assemblies into a local folder, and then add a reference to the assembly from this folder. You may want to set the "Copy Local" property to False for that assembly if you do not want the assembly to be copied
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
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...
1
7413
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
6675
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
5310
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.