WCF:在VS2010中自动禁用从DEBUG到RELEASE构建的MEX吗?

时间:2010-11-09 05:44:53

标签: wcf mex mex-bindings

我有一些代码可以在安装了我们产品的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

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

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

相关问题