我尝试调用的方法具有以下签名:
结果GetPerformanceData(MyEntity实体,bool recurse);
我在方法的开头设置了一个断点,但是在代码执行到达断点之前抛出了异常.
跟踪WCF服务向我提供以下信息:
System.NullReferenceException,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089对象引用未设置为对象的实例.StackTrace:位于System.Runtime.Serialization.CodeGenerator.Call(Object thisObj,MethodInfo methodInfo,Object param1)的System.Runtime.Serialization.CodeGenerator.VerifyParameterCount(MethodInfo methodInfo,Int32 expectedCount)at ...
如何确定null变量是什么?我的调试器设置为中断所有异常,但它并没有打破这个特定的问题.看起来我试图调用的方法的"实体"参数无法正确反序列化.
示例调用调用
var results = client.GetPerformanceData(entity,true);
WCF服务配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="All"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "trace.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingSettings" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="5242880" maxBufferPoolSize="52428800" maxReceivedMessageSize="5242880"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="64" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Company.Service.Engine"
behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Engine"/>
</baseAddresses>
</host>
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingSettings"
contract="Company.Service.IEngine"/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
事实证明,我有一些标记为[DataMember]的属性,它们有吸气剂,但没有固定器.
通常,通过查看服务上的跟踪文件或在客户端项目上添加服务引用时的弹出窗口中,我会收到描述性错误.这次我没有.
我不得不搜索[DataMember]的所有实例并逐个查看它们以找到缺少setter的属性.
| 归档时间: |
|
| 查看次数: |
7931 次 |
| 最近记录: |