![]() |
Languages »
C# »
Applications
Beginner
License: The Code Project Open License (CPOL)
How can you load .NET assemblies dynamiclyBy Steingrebenot really a new but a Solution |
C#, .NET (.NET 2.0), ASP.NET, ADO.NET, Dev
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This is my first English article, so excuse my horrible English.
The first Time i start to develop a .NET Application i had to load a DLL dynamicly. Puh... I don't
know how but i wrote a Function to do that.
Next Time i need a Function to load a DLL from a Interface. Ok Copy the first Function and change the Parameters.
After that i must load not only one DLL so we can have many. Ok Copy the first Function and change the Parameters.
Hmm, wait a moment. There is many Space to do it in the generic way.
The Generic way means that you have, at designtime, no Idea what objects at runtime you will work with.
public static class ModuleLoader<T>
Functionlist:
Load only one Module
public static T LoadModule(Guid moduleId)
public static T LoadModule(Guid moduleId, string path)
public static T LoadModule(Guid moduleId, string path, string fileExtension)
Load a list of Modules
public static List<T> LoadModuleList()
public static List<T> LoadModuleList(string path)
public static List<T> LoadModuleList(Guid moduleId, string path, string fileExtension)
When you want to load a list of Modules, i think you will use a Interface as T
Example:
Loads all Assemblies that implement the IPlugIn Interface in the current Directory
List<IPlugIn> pluginList = ModuleLoader<IPlugIn>.LoadModuleList();
Loads a given Assembly that implement the IPlugIn Interface in the current Directory. Where pluginId the TypeGuid of the given PlugIn is.
IPlugIn plugin = ModuleLoader<IPlugIn>.LoadModule(pluginId);
In the next Article i will explain how you can use the ModuleLoader with a AppDomain to load and unload at runtime.
| You must Sign In to use this message board. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 1 Apr 2008 Editor: |
Copyright 2008 by Steingrebe Everything else Copyright © CodeProject, 1999-2009 Web22 | Advertise on the Code Project |