SerializationException: Type is not resolved for member “…”

久未见 提交于 2020-01-14 07:02:27

问题


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 "..."

Here's my code:

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);
}

回答1:


Answer: The type had to extend MarshalByRefObject.



来源:https://stackoverflow.com/questions/13729089/serializationexception-type-is-not-resolved-for-member

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!