对象序列化的问题 [英] Problem with serialization of objects

查看:103
本文介绍了对象序列化的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试返回一个复杂类型的对象的集合(一个List)(每个对象内部都有大约20-30个自定义对象)时,出现此错误:

测试方法SMILTest.ServiceManagerTest.PessoasTest引发了异常:System.ServiceModel.CommunicationObjectFaultedException:通信对象System.ServiceModel.Security.SecuritySessionClientSettings`1 + ClientSecurityDuplexSessionChannel [System.ServiceModel.Channels.IDuplexSessionChannel]无法用于通讯,因为它处于故障状态..

在System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecurityDuplexSessionChannel.TryReceive(TimeSp超时,Message&消息)
在System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(消息消息,TimeSpan超时)
在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔型单向,ProxyOperationRuntime操作,Object [] ins, Object []超时,TimeSpan超时)
,位于System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime操作,Object [] ins,Object [] outs)
在System.ServiceModel.Channels .ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)
在System.ServiceModel.Channels.ServiceChannelProxy.Invoke( IMessage消息)

在[0]处引发异常:
在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)

在HGM.ERP.ServiceContractInterfaces.Cadastros.ICadastros.PessoasConsultar(PessoasDFO filtro)
在C:\ VSS \ ERP \ Service Manager基础结构库\ SMILTest \中的SMILTest.ServiceManagerTest.PessoasTest() ServiceManagerTest.cs:line 116

如果我尝试接收最多5个对象,则没有错误,但是6个或更多对象将引发所描述的错误.在这种情况下,完整的对象图最多应包含180(6 * 30)个对象和大约10 KB.我尝试将"OperationBehavior.MaxItemsInObjectGraph"设置为和MaxReceivedMessageSize到Int32.MaxValue进行测试,但是我最多可以发送5个对象.

当我使用NetDataContractSerializer而不是默认的DataContractSerializer时,我只是使用WCF默认的DataContract对其进行了测试,并且错误是相同的.

When I try to return a collection (an List<>) of a complex kind of object (each one have about 20-30 custom objects inside) I get this error:

Test method SMILTest.ServiceManagerTest.PessoasTest threw exception:  System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Security.SecuritySessionClientSettings`1+ClientSecurityDuplexSessionChannel[System.ServiceModel.Channels.IDuplexSessionChannel], cannot be used for communication because it is in the Faulted state..

Server stack trace:
   at System.ServiceModel.Channels.CommunicationObject.ThrowIfFaulted()
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecurityDuplexSessionChannel.TryReceive(TimeSpan timeout, Message& message)
   at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at HGM.ERP.ServiceContractInterfaces.Cadastros.ICadastros.PessoasConsultar(PessoasDFO filtro)
   at SMILTest.ServiceManagerTest.PessoasTest() in C:\VSS\ERP\Service Manager Infrastructure Library\SMILTest\ServiceManagerTest.cs:line 116

If I try to receive up to 5 objects there's no error but 6 or more objects will throw the error described. The full object graph in this case should have up to 180 (6 * 30) objects and about 10 KB. I try to set "OperationBehavior.MaxItemsInObjectGraph" and MaxReceivedMessageSize to Int32.MaxValue for test but I could send up to 5 objects.

As I'm using a NetDataContractSerializer instead the default DataContractSerializer I just test it with the WCF default DataContract and the error is the same.

推荐答案

您可以启用跟踪并查看服务器上的详细异常,这可能会有所帮助

you can enable tracing and see the detailed exception on server and that might help


这篇关于对象序列化的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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