【问题标题】:WCF: Automatically disable MEX from DEBUG to RELEASE builds in VS2010?WCF:在 VS2010 中自动禁用 MEX 从 DEBUG 到 RELEASE 构建?
【发布时间】:2010-11-09 05:44:52
【问题描述】:

我的代码可以在安装我们产品的 RELEASE 版本时自动禁止故障信息流向客户端。我想知道是否有一种聪明的方法可以让 MEX 元数据在我们的 RELEASE 版本中不可用。这是我为自动禁用故障信息所做的工作,我在以下链接中找到了这些信息:http://codeidol.com/csharp/wcf/Faults/Fault-Contracts/

    // Enables exceptions to flow to clients when built for debugging; 
    // Otherwise, no details go to client.
    public static class DebugHelper
    {
        public const bool IncludeExceptionDetailInFaults =
#if DEBUG
 true;
#else
      false;
#endif
    }

    // This service is singleton.  If other calls arrive while one is in progress, 
    // they are queued.
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, 
                     ConcurrencyMode = ConcurrencyMode.Single, 
                     IncludeExceptionDetailInFaults = DebugHelper.IncludeExceptionDetailInFaults)]
    public class OurService : IOurService

【问题讨论】:

    标签: wcf mex mex-bindings


    【解决方案1】:

    如果您使用配置文件配置 WCF 服务,那么您可能只有两个单独的配置 - 一个用于调试,一个用于不带 MEX 端点的发布。

    【讨论】:

      【解决方案2】:

      您应该在代码中添加 mex 端点,然后将其编译掉

      【讨论】:

      • 啊……我喜欢你的两个想法,但是这个很吸引人,因为我可以使用条件编译,而不必维护两个配置文件。这是要走的路!谢谢马克和普里特的帮助! :) -- 迈克
      猜你喜欢
      • 1970-01-01
      • 2021-06-09
      • 1970-01-01
      • 2017-06-14
      • 2013-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多