如何避免SerializationException:在测试使用LogicalCallContext的组件时,不会为成员解析类型 [英] How to avoid SerializationException: Type is not resolved for member when testing a component that uses the LogicalCallContext

查看:69
本文介绍了如何避免SerializationException:在测试使用LogicalCallContext的组件时,不会为成员解析类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要指导如何避免序列化异常。



System.Runtime.Serialization.SerializationException:成员[我的类型名称],[我的程序集]的类型未解析name]

need to guide how to avoid serializationException.

System.Runtime.Serialization.SerializationException : Type is not resolved for member [my type name], [my assembly name]

推荐答案

MarshalByRefObject 类继承你的类。



As每个MSDN:

MarshalByRefObject是通过使用代理交换消息跨应用程序域边界进行通信的对象的基类。不从MarshalByRefObject继承的对象按值隐式编组。当远程应用程序引用按值对象编组时,对象的副本将跨应用程序域边界传递。



https://msdn.microsoft.com/en-us/library/system.marshalbyrefobject(v=vs.110) .aspx [ ^ ]

Inherit your class from MarshalByRefObject class.

As per MSDN:
MarshalByRefObject is the base class for objects that communicate across application domain boundaries by exchanging messages using a proxy. Objects that do not inherit from MarshalByRefObject are implicitly marshal by value. When a remote application references a marshal by value object, a copy of the object is passed across application domain boundaries.

https://msdn.microsoft.com/en-us/library/system.marshalbyrefobject(v=vs.110).aspx[^]
public class ClassName : MarshalByRefObject
{
    // Define functions, properties..
}


这篇关于如何避免SerializationException:在测试使用LogicalCallContext的组件时,不会为成员解析类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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