SerializationException: Type is not resolved for m

2019-06-15 01:21发布

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

标签: c# appdomain
1条回答
SAY GOODBYE
2楼-- · 2019-06-15 02:02

Answer: The type had to extend MarshalByRefObject.

查看更多
登录 后发表回答