当我们安装产品的RELEASE版本时,我的代码会自动将错误信息从流向客户端的流程中排除。我想知道是否有一种聪明的方法,我们也可以禁用MEX元数据,使其在我们的RELEASE构建中可用。以下是我所做的自动禁用故障信息的操作,我在以下链接中找到了这些信息:http://codeidol.com/csharp/wcf/Faults/Fault-Contracts/。WCF:自动禁用MEX从DEBUG到RELEASE在VS2010中生成?
// 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
Ahhh ...我喜欢你的两个想法,但这个很吸引人,因为我可以使用条件编译,而不必维护两个配置文件。这是要走的路!感谢Mark&Preet的帮助! :) - Mike – ABOH 2010-11-09 22:41:32
不客气。祝你好运 – 2010-11-10 02:45:26