在服务器上打开IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute或从< serviceDebug>配置行为) [英] Turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server

查看:776
本文介绍了在服务器上打开IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute或从< serviceDebug>配置行为)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我得到这个例外:

我有一个WCF服务已经完美工作,有些事情发生了变化,


System.ServiceModel.FaultException:由于内部错误,服务器无法处理请求。有关错误的更多信息,请打开服务器上的IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute或从配置行为),以便将异常信息发送回客户端,或根据Microsoft .NET Framework 3.0 SDK文档打开跟踪并检查服务器跟踪日志。


这是令人困惑的,因为我正在运行.NET 4.0。



我在哪里开启 IncludeExceptionDetailInFaults ?我正在努力寻找它。

解决方案

定义一个 .config 文件中的en-us / library / aa967282%28v = vs.110%29.aspxrel =noreferrer>行为: p>



 < configuration> 
< system.serviceModel>
<行为>
< serviceBehaviors>
< behavior name =debug>
< serviceDebug includeExceptionDetailInFaults =true/>
< / behavior>
< / serviceBehaviors>
< / behavior>
...
< /system.serviceModel>
< / configuration>

然后通过以下行将行为应用于您的服务:

 < configuration> 
< system.serviceModel>
...
< services>
< service name =MyServiceNamebehaviorConfiguration =debug/>
< / services>
< /system.serviceModel>
< / configuration>

您还可以通过编程方式进行设置。请参阅此问题


I have a WCF service that has been working perfectly, and something has changed and I don't know what.

I get this exception:

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.

This is confusing because I am running .NET 4.0.

Where do I turn on IncludeExceptionDetailInFaults? I'm battling to find it.

解决方案

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或从&lt; serviceDebug&gt;配置行为)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆