問題描述
我有一個運行良好的 WCF 服務,但發生了一些變化,我不知道是什么.
I have a WCF service that has been working perfectly, and something has changed and I don't know what.
我得到了這個例外:
System.ServiceModel.FaultException:由于內部錯誤,服務器無法處理請求.有關錯誤的更多信息,請在服務器上打開 IncludeExceptionDetailInFaults(來自 ServiceBehaviorAttribute 或來自配置行為)以便將異常信息發送回客戶端,或者根據 Microsoft .NET Framework 3.0 SDK 文檔打開跟蹤并檢查服務器跟蹤日志.
System.ServiceModel.FaultException: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
這很令人困惑,因為我運行的是 .NET 4.0.
This is confusing because I am running .NET 4.0.
在哪里打開 IncludeExceptionDetailInFaults
?我正在努力尋找它.
Where do I turn on IncludeExceptionDetailInFaults
? I'm battling to find it.
推薦答案
定義一個行為 在您的 .config
文件中:
Define a behavior in your .config
file:
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
...
</system.serviceModel>
</configuration>
然后按照以下方式將行為應用于您的服務:
Then apply the behavior to your service along these lines:
<configuration>
<system.serviceModel>
...
<services>
<service name="MyServiceName" behaviorConfiguration="debug" />
</services>
</system.serviceModel>
</configuration>
您也可以通過編程方式進行設置.請參閱這個問題.
You can also set it programmatically. See this question.
這篇關于在服務器上打開 IncludeExceptionDetailInFaults(來自 ServiceBehaviorAttribute 或來自 <serviceDebug> 配置行為)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!