ABOH
ABOH

Reputation: 61

WCF: Automatically disable MEX from DEBUG to RELEASE builds in VS2010?

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

Upvotes: 1

Views: 688

Answers (2)

marc_s
marc_s

Reputation: 755237

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.

Upvotes: 2

Preet Sangha
Preet Sangha

Reputation: 65546

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

Upvotes: 1

Related Questions