0
我有一个DLL,我需要成为当前AppDomain的一部分。有没有办法指示AppDomain从app.config/web.config中的某个列表中选取dll?从App.Config将程序集加载到AppDomain中
我有一个DLL,我需要成为当前AppDomain的一部分。有没有办法指示AppDomain从app.config/web.config中的某个列表中选取dll?从App.Config将程序集加载到AppDomain中
您可以将程序集的名称放在app.config文件中,然后使用Assembly.Load选项和反射在运行时加载它。这里是MSDN文章描述如何做到这一点的链接。
http://msdn.microsoft.com/en-us/library/25y1ya39.aspx
基础在app.config文件汇编的
实施例:
public class Asmload0
{
public static void Main()
{
// Use the file name to load the assembly into the current
// application domain.
Assembly a = Assembly.Load("example");
// Get the type to use.
Type myType = a.GetType("Example");
// Get the method to call.
MethodInfo myMethod = myType.GetMethod("MethodA");
// Create an instance.
object obj = Activator.CreateInstance(myType);
// Execute the method.
myMethod.Invoke(obj, null);
}
}