Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我只能序列化167条记录。任何其他异常都会引发类型为';的未处理异常;System.StackOverflowException';发生在mscorlib.dll中_C#_.net_Wcf_Silverlight_Serialization - Fatal编程技术网

C# 我只能序列化167条记录。任何其他异常都会引发类型为';的未处理异常;System.StackOverflowException';发生在mscorlib.dll中

C# 我只能序列化167条记录。任何其他异常都会引发类型为';的未处理异常;System.StackOverflowException';发生在mscorlib.dll中,c#,.net,wcf,silverlight,serialization,C#,.net,Wcf,Silverlight,Serialization,老实说,我已经筋疲力尽了,我真的不知道该怎么办。我正在使用Silverlight wcf开发Silverlight应用程序。我的网络配置如下所示: <system.web> <httpRuntime maxRequestLength="2147483647" /> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.diagnostics> &

老实说,我已经筋疲力尽了,我真的不知道该怎么办。我正在使用Silverlight wcf开发Silverlight应用程序。我的网络配置如下所示:

<system.web>
<httpRuntime maxRequestLength="2147483647" />
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information,Error,ActivityTracing"     propagateActivity="true" >
<listeners>
<add name="xml" />
</listeners>
        </source>
        <source name="CardSpace">
            <listeners>
                <add name="xml" />
            </listeners>
        </source>
        <source name="System.IO.Log">
            <listeners>
                <add name="xml" />
            </listeners>
        </source>
        <source name="System.Runtime.Serialization" switchValue="Information,Error,ActivityTracing">
            <listeners >
                <add name="xml" />
            </listeners>
        </source>
        <source name="System.IdentityModel">
            <listeners>
                <add name="xml" />
            </listeners>
        </source>

        <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
        </source>
        <source name="myUserTraceSource"
                switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
        </source>
    </sources>
    <sharedListeners>
        <add name="xml"
             type="System.Diagnostics.XmlWriterTraceListener"
                   initializeData="e:\Traces.svclog"

             />
    </sharedListeners>
</system.diagnostics>


<system.serviceModel>

    <diagnostics>
        <messageLogging
 logEntireMessage="true"
 logMalformedMessages="true"
 logMessagesAtServiceLevel="true"
 logMessagesAtTransportLevel="true"
 maxMessagesToLog="3000"
  maxSizeOfMessageToLog="2147483647"
 />

    </diagnostics>

    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>

    <bindings>
        <basicHttpBinding>
            <binding name="ServicesBinding" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
             maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                 maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </binding>
        </basicHttpBinding>
    </bindings>


    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
        <service behaviorConfiguration="ServiceBehavior" name="SUS.Web.Services.BaseService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding"
             contract="SUS.Web.Services.BaseService" />
        </service>
        <service behaviorConfiguration="ServiceBehavior" name="SUS.Web.Services.NuggetServices">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding"
             contract="SUS.Web.Services.NuggetServices" />
        </service>
        <service behaviorConfiguration="ServiceBehavior" name="SUS.Web.Services.WorkspaceServices">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding"
             contract="SUS.Web.Services.WorkspaceServices" />
        </service>
        <service behaviorConfiguration="ServiceBehavior" name="SUS.Web.Services.GeneralTemplateService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding"
             contract="SUS.Web.Services.GeneralTemplateService" />
        </service>
        <service behaviorConfiguration="ServiceBehavior" name="SUS.Web.Services.QueryService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="ServicesBinding"
             contract="SUS.Web.Services.QueryService" />

        </service>
    </services>
</system.serviceModel>        
有趣的是:

我已从以下属性中删除所有构造函数:

private ObservableCollection<VmNugget> my;
[DataMember]
public ObservableCollection<VmNugget> My
get{
/* commented
if (this.my == null)
 this.my = new ObservableCollection<VmNugget>();
*/ 
return this.my;
}
private observeCollection my;
[数据成员]
公众可观察收集我的
得到{
/*评论
if(this.my==null)
this.my=新的ObservableCollection();
*/ 
把这个还给我;
}
我试图将167多个空对象放入返回的集合,但无法序列化它们并发送到客户端。这些对象应为空(未初始化)

我使用VmQuery类和OBservableCollection in Rows属性发送它

多谢各位


Tomas

确保没有无限循环或无限递归。 太多的方法调用通常表示非常深或无限的递归


我的视图模型非常复杂,可以相互包含,一个可以是另一个的祖先。

这可能就是你的问题所在。我怀疑您有两个对象,它们之间有一个循环引用,并且serialiser溢出了。检查这一点的一种方法是尝试一次序列化每个对象(及其子对象)。我敢打赌,其中一个(或可能更多)会表现出你所描述的行为


考虑按ID而不是按完整对象本身序列化对子对象的引用。

非常感谢。我终于找到了。在一个属性中,我使用了OBservableCollection后代。该类添加了一个极好的功能,可以记住对每个包含对象的父集合的引用。:-)解决了,我还活着。世界是如此美丽

private ObservableCollection<VmNugget> my;
[DataMember]
public ObservableCollection<VmNugget> My
get{
/* commented
if (this.my == null)
 this.my = new ObservableCollection<VmNugget>();
*/ 
return this.my;
}