我们加载组件(一个DLL)读取一个配置文件。我们需要更改配置文件,然后重新加载程序集。我们发现第二次加载程序集后,配置没有任何变化。 有人看到这里有什么问题吗?我们在配置文件中省略了阅读的细节。如何重新加载.NET应用程序域的程序集?
AppDomain subDomain;
string assemblyName = "mycli";
string DomainName = "subdomain";
Type myType;
Object myObject;
// Load Application domain + Assembly
subDomain = AppDomain.CreateDomain(DomainName,
null,
AppDomain.CurrentDomain.BaseDirectory,
"",
false);
myType = myAssembly.GetType(assemblyName + ".mycli");
myObject = myAssembly.CreateInstance(assemblyName + ".mycli", false, BindingFlags.CreateInstance, null, Params, null, null);
// Invoke Assembly
object[] Params = new object[1];
Params[0] = value;
myType.InvokeMember("myMethod", BindingFlags.InvokeMethod, null, myObject, Params);
// unload Application Domain
AppDomain.Unload(subDomain);
// Modify configuration file: when the assembly loads, this configuration file is read in
// ReLoad Application domain + Assembly
// we should now see the changes made in the configuration file mentioned above
为什么你的东东d在更新配置文件后重新加载组件?它是否包含动态创建的类型定义? – 2009-06-21 14:52:05
米奇 - 是的他们做 – 2009-06-23 07:49:48