簡體   English   中英

沒有參數時的WCF System.ArgumentNullException

[英]WCF System.ArgumentNullException when there's no argument

我遇到了沒有參數的WCF服務方法的問題,但是當調用它時,我得到了System.ArgumentNullException,該錯誤僅在部署服務時發生,在Visual Studio上的調試中一切正常。

要求:

 <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測試客戶端

我搜索了很多東西,卻找不到答案,我真的需要幫助,在此先感謝。

當將null傳遞給System.Number.ParseInt32方法時,將在XXXX.ExportDailyFile類的構造期間發生異常。 這可能是在無參數構造函數中發生的,或者您有一個以System.Number.ParseInt32初始化的類級別字段。 在您的班級中搜索System.Number.ParseInt32 ,您應該能夠確定罪魁禍首。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM