【问题标题】:Unwrapping a non-serializable class from an appdomain从 appdomain 中解包不可序列化的类
【发布时间】:2011-08-31 14:20:07
【问题描述】:

因为并非我要实例化的类中使用的所有类都是可序列化的,所以我无法解包。

这可能吗?

var appdom = AppDomain.CreateDomain(amServiceable.GetType().ToString());
var objectHandle = appdom.CreateInstance(amServiceable.GetType().Assembly.FullName, 
                                         amServiceable.GetType().FullName);


var plugin = objectHandle.Unwrap() as IPlugin //throws an error. that some class in not marked serializable.

【问题讨论】:

    标签: c# reflection appdomain


    【解决方案1】:

    为了在对象上使用Unwrap 方法,它必须从MarshalByRefObject 派生。如果您要操作的对象没有,那么唯一的其他选择是使用不同的MarshalByRefObject 来操作其他域中的对象

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-20
      • 1970-01-01
      • 1970-01-01
      • 2011-12-01
      • 2014-12-10
      • 1970-01-01
      • 2011-01-24
      • 1970-01-01
      相关资源
      最近更新 更多