我一直在尝试将程序集动态加载到 AppDomain。我需要这样做是因为我想动态调用一个方法,但在我的应用程序运行时不要保留 DLL 的句柄,以便在需要时可以替换它。但我收到此 SerializationException 异常:类型未解析成员“...”
这是我的代码:
AppDomain domain = AppDomain.CreateDomain("Temp AppDomain", null, AppDomain.CurrentDomain.SetupInformation);
try {
object obj = domain.CreateInstanceFromAndUnwrap(dllPath, typeName);
IMyInterface myObj = (IMyInterface) obj;
result = myObj.MyMethod(something);
}
finally {
AppDomain.Unload(domain);
}
最佳答案
答案:类型必须扩展MarshalByRefObject
。
关于c# - 序列化异常 : Type is not resolved for member "...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13729089/