【问题标题】:IncludeExceptionDetailInFaults in code for a single service contract单个服务合同的代码中的 IncludeExceptionDetailInFaults
【发布时间】:2013-07-25 07:26:57
【问题描述】:

之前的问题我都看过了---

Turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server

Set IncludeExceptionDetailInFaults to true in code for WCF

很遗憾,这两个问题都无法解决我的目的。

我只想为特定 ServiceHost 可能正在处理的许多合同中的一个合同启用 IncludeExceptionDetailsInFaults。一个 ServiceHost 可能有多个端点用于不同的合同,但我只需要为其中任何一个启用此调试功能

【问题讨论】:

    标签: c# .net wcf


    【解决方案1】:

    IncludeExceptionDeatilsInFaults 不能配置到特定的合约,它是 ServiceBehavior 的一部分。

    您可以指定自定义故障,捕获操作中的所有异常,您希望将所有异常信息返回给客户端并返回您的特定故障。

    注意返回原始异常对象的错误,因为某些异常无法序列化。如果您创建自己的故障,则可以向其添加异常消息和堆栈跟踪。

    【讨论】:

      猜你喜欢
      • 2011-01-29
      • 2019-08-18
      • 1970-01-01
      • 2012-03-22
      • 2020-05-18
      • 1970-01-01
      • 1970-01-01
      • 2016-10-20
      • 1970-01-01
      相关资源
      最近更新 更多