問題描述
我有一個(gè)運(yùn)行良好的 WCF 服務(wù),但發(fā)生了一些變化,我不知道是什么.
I have a WCF service that has been working perfectly, and something has changed and I don't know what.
我得到了這個(gè)例外:
System.ServiceModel.FaultException:由于內(nèi)部錯(cuò)誤,服務(wù)器無法處理請求.有關(guān)錯(cuò)誤的更多信息,請?jiān)诜?wù)器上打開 IncludeExceptionDetailInFaults(來自 ServiceBehaviorAttribute 或來自配置行為)以便將異常信息發(fā)送回客戶端,或者根據(jù) Microsoft .NET Framework 3.0 SDK 文檔打開跟蹤并檢查服務(wù)器跟蹤日志.
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.
這很令人困惑,因?yàn)槲疫\(yùn)行的是 .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.
推薦答案
定義一個(gè)行為 在您的 .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>
然后按照以下方式將行為應(yīng)用于您的服務(wù):
Then apply the behavior to your service along these lines:
<configuration>
<system.serviceModel>
...
<services>
<service name="MyServiceName" behaviorConfiguration="debug" />
</services>
</system.serviceModel>
</configuration>
您也可以通過編程方式進(jìn)行設(shè)置.請參閱這個(gè)問題.
You can also set it programmatically. See this question.
這篇關(guān)于在服務(wù)器上打開 IncludeExceptionDetailInFaults(來自 ServiceBehaviorAttribute 或來自 <serviceDebug> 配置行為)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!