【发布时间】:2009-07-07 23:27:30
【问题描述】:
我尝试调用的方法具有以下签名:
Results GetPerformanceData(MyEntity entity, bool recurse);
我在方法的开头设置了一个断点,但是在代码执行到达断点之前就抛出了异常。
跟踪 WCF 服务可以得到以下信息:
System.NullReferenceException,mscorlib,版本=2.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089 你调用的对象是空的。 堆栈跟踪: 在 System.Runtime.Serialization.CodeGenerator.VerifyParameterCount(MethodInfo 方法信息,Int32 预期计数) 在 System.Runtime.Serialization.CodeGenerator.Call(对象 thisObj,MethodInfo methodInfo,对象 param1) 在...
如何确定空变量是什么?我将调试器设置为中断所有异常,但对于这个特定问题并没有中断。看起来我试图调用的方法的“实体”参数无法正确反序列化。
示例调用调用
var 结果 = 客户。 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>
【问题讨论】:
-
如果您能提供调用代码和WCF配置会有所帮助,
标签: wcf