Turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the lt;serviceDebuggt; configuration behavior) on the server(在服务器上打开 IncludeExceptionDetailInFaults(来自 ServiceBehaviorAttribute 或来自 lt;serviceDebuggt; 配置行为))
问题描述
我有一个运行良好的 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> 配置行为)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在服务器上打开 IncludeExceptionDetailInFaults(来自 S


- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 如何用自己压缩一个 IEnumerable 2022-01-01