老实说,我已经筋疲力尽了,我真的不知道该怎么办。我正在使用 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 类发送它。
非常感谢。
托马斯