0

老实说,我已经筋疲力尽了,我真的不知道该怎么办。我正在使用 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>        

我在服务器和 Silverlight 项目之间共享程序集,因此我可以在它们之间发送类。服务器生成 250 个对象。我可以将它们发送到最多 167 个的集合中。我可以从这 250 个 VmNugget 对象中选择任何 167 个对象,这不是任何具体对象的问题。我的 ViewModel 非常复杂,可以相互包含,一个可以是另一个的祖先。我的类用 [DataContract] 和 [DataMember] 属性装饰。你有什么提示我如何在序列化过程中检查这个过程?我的 webService 是这样装饰的:

[ServiceKnownType(typeof(VmCulture))]
[ServiceKnownType(typeof(VmNugget))]
[ServiceKnownType(typeof(VmDesignedNugget))]
[ServiceKnownType(typeof(VmDesigner))]
[ServiceKnownType(typeof(OperationLog))]
[ServiceKnownType(typeof(OperationLog))]
[ServiceKnownType(typeof(VmFile))]
[ServiceKnownType(typeof(VmQuery))]
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class QueryService : BaseService

有趣的事:

我已经从这样的属性中删除了所有构造函数:

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

我试图将超过 167 个空对象放入返回的集合中,但我无法将它们序列化并发送给客户端。这些对象应该是空的(未初始化)。

我使用带有 OBservableCollection in Rows 属性的 VmQuery 类发送它。

非常感谢。

托马斯

4

3 回答 3

2

My ViewModels are pretty complex, can contain each other and one can be ancestor of another one.

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

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

于 2013-10-02T08:58:05.097 回答
0

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

MSDN

于 2013-10-02T08:45:30.343 回答
0

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

于 2013-10-02T11:08:39.360 回答