从appdomain解包不可序列化的类

alb*_*jan 4 c# reflection appdomain

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

这可能吗?

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.
Run Code Online (Sandbox Code Playgroud)

Jar*_*Par 5

为了Unwrap在对象上使用该方法,它必须从中派生出来MarshalByRefObject.如果您想要操作的对象没有,那么唯一的另一种选择是使用不同MarshalByRefObject的操作来操纵另一个域中的对象