WCF System.ArgumentNullException 当没有参数时

WCF System.ArgumentNullException when there's no argument

我在使用没有参数的 WCF 服务方法时遇到问题,但在调用它时我得到一个 System.ArgumentNullException,该错误仅在部署服务时发生,在 [=25] 上进行调试=] 一切正常。

请求:

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:CanExecute/>
   </soapenv:Body>
</soapenv:Envelope>

答案:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <s:Fault>
         <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
         <faultstring xml:lang="pt-BR">Value cannot be null.
Parameter name: String</faultstring>
         <detail>
            <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
               <HelpLink i:nil="true"/>
               <InnerException i:nil="true"/>
               <Message>Value cannot be null.
Parameter name: String</Message>
               <StackTrace>at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at XXXX.ExportDailyFile..ctor()
   at XXXX.ExportDailyFile()
   at System.ServiceModel.InstanceContext.GetServiceInstance(Message message)
   at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
               <Type>System.ArgumentNullException</Type>
            </ExceptionDetail>
         </detail>
      </s:Fault>
   </s:Body>
</s:Envelope>

当我使用 WCF 测试客户端调用时: WCF Test Client

我搜索了很多,找不到答案,我真的需要帮助,在此先感谢。

null 被传递给 System.Number.ParseInt32 方法时,XXXX.ExportDailyFile class 的构造期间发生异常。这要么发生在无参数构造函数中,要么您有一个 class 级别字段,该字段以 System.Number.ParseInt32 开头。在 class 中搜索 System.Number.ParseInt32,您应该能够确定罪魁祸首。