WCF:在 VS2010 中自动禁用 MEX 从 DEBUG 到 RELEASE 构建?
我有代码可以在安装我们产品的发布版本时自动禁止故障信息流向客户端。我想知道是否有一种聪明的方法可以让我们在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用配置文件配置 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.
您应该在代码中添加 mex 端点,然后将其编译掉
You should add the mex endpoint in code and thus compile it away