本文介绍了SerializationException:未解析成员“..."的类型;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试将程序集动态加载到 AppDomain.我需要这样做,因为我想动态调用一个方法,但不要在我的应用程序运行时保留 DLL 的句柄,以便在需要时可以替换它.但是我收到了这个 SerializationException 异常:成员..."的类型未解析
I've been trying to dynamically load an assembly to an AppDomain. I need to do it because I want to call a method dynamically, but don't keep the handle to the DLL while my app is running, so that it can be replaced, if needed. But I'm getting this SerializationException exception: Type is not resolved for member "..."
这是我的代码:
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
.
Answer: The type had to extend MarshalByRefObject
.
这篇关于SerializationException:未解析成员“..."的类型;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!