SerializationException:类型未解决的成员" ..." [英] SerializationException: Type is not resolved for member "..."

查看:240
本文介绍了SerializationException:类型未解决的成员" ..."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图动态加载程序集到一个AppDomain。我需要做的,因为我想动态调用一个方法,但处理我的应用程序运行时不保持到DLL,因此,它可以更换,如果需要的话。但我得到这个SerializationException异常:类型未解决的成员...



下面是我的代码:

 的AppDomain域= AppDomain.CreateDomain(临时的AppDomain,空,AppDomain.CurrentDomain.SetupInformation); 
尝试{
obj对象= domain.CreateInstanceFromAndUnwrap(DllPath的,typeName的);
IMyInterface的MyObj中=(IMyInterface的)目标文件;
结果= myObj.MyMethod(东西);
}
终于{
AppDomain.Unload(域);
}


解决方案

答:类型必须延长 MarshalByRefObject的


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

解决方案

Answer: The type had to extend MarshalByRefObject.

这篇关于SerializationException:类型未解决的成员" ..."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆