1

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
Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
ABOH
  • 61
  • 1
  • 6

2 Answers2

2

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
1

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

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
  • Ahhh... I like both of your ideas, but this one is very appealing because I can use conditional compilation and don't have to maintain two config files. This is the way to go! Thank you Mark & Preet for your help! :) -- Mike – ABOH Nov 09 '10 at 22:41