开发者

Unwrapping a non-serializable class from an appdomain

开发者 https://www.devze.com 2023-04-01 18:09 出处:网络
Because not all the classes used in the class I want to instantiate are serializable I can\'t unwrap.

Because not all the classes used in the class I want to instantiate are serializable I can't unwrap.

Is this possible?

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 cla开发者_如何学Pythonss in not marked serializable.


In order to use the Unwrap method on an object it must derive from MarshalByRefObject. If the object you want to manipulate doesn't then the only other choice is to use a different MarshalByRefObject to manipulate the object in the other domain

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号