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

发布于 2024-09-30 22:34:18 字数 933 浏览 0 评论 0原文

我有代码可以在安装我们产品的发布版本时自动禁止故障信息流向客户端。我想知道是否有一种聪明的方法可以让我们在 RELEASE 版本中禁用 MEX 元数据。以下是我为自动禁用故障信息所做的操作,我在以下链接中找到了该信息: 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

I have code that automatically disbles fault information from flowing to clients when a RELEASE build of our product in installed. I am wondering whether there is a clever way that we can also disable MEX metadata from being available in our RELEASE build. Here is what I've done to automatically disable fault information, which I found at the following link: 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花开柳相依 2024-10-07 22:34:18

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

If you configure your WCF service using a config file, then you could just have two separate configs - one for debug, one for release without the MEX endpoint.

时光倒影 2024-10-07 22:34:18

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

You should add the mex endpoint in code and thus compile it away

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文