views:

604

answers:

3

In this question the answer was to flip on a switch that is picked up by the debugger disabling the extraneous header that was causing the problem. The Microsoft help implies these switched are user generated and does not list any switches.

<configuration>
  <system.diagnostics>
    <switches>
      <add name="Remote.Disable" value="1" />
    </switches>
  </system.diagnostics>
</configuration>

What I would like to know is where the value "Remote.Disable" comes from and how find out what other things can be switched on or off. Currently it is just some config magic, and I don't like magic.

+1  A: 

You can use Reflector to search for uses of the Switch class and its subclasss (BooleanSwitch, TraceSwitch, etc). The various switches are hardcoded by name, so AFAIK there's no master list somewhere.

Kevin Dente
Hi, what assemblies do you need to have open to find these? With the default set open in Reflector I'm not finding any matches...
rohancragg
TraceSwitch is in System.Diagnostics (System.dll) which should be in the default set for Reflector.
Darryl Braaten
+2  A: 

As you suspected, Remote.Disable stops the app from attaching debug info to remote requests. It's defined inside the .NET framework methods that make the SOAP request.

The basic situation is that these switches can be defined anywhere in code, you just need to create a new System.Diagnostics.BooleanSwitch with the name given and the config file can control them.

This particular one is defined in System.ComponentModel.CompModSwitches.DisableRemoteDebugging:

public static BooleanSwitch DisableRemoteDebugging
{
    get
    {
        if (disableRemoteDebugging == null)
        {
            disableRemoteDebugging = new BooleanSwitch("Remote.Disable", "Disable remote debugging for web methods.");
        }
        return disableRemoteDebugging;
    }
}

In your case it's probably being called from System.Web.Services.Protocols.RemoteDebugger.IsClientCallOutEnabled(), which is being called by System.Web.Services.Protocols.WebClientProtocol.NotifyClientCallOut which is in turn being called by the Invoke method of System.Web.Services.Protocols.SoapHttpClientProtocol

Unfortunately, to my knowledge, short of decompiling the framework & seaching for

new BooleanSwitch

or any of the other inheritors of the System.Diagnostics.Switch class, there's no easy way to know what switches are defined. It seems to be a case of searching msdn/google/stack overflow for the specific case

In this case I just used Reflector & searched for the Remote.Disable string

Glenn Slaven
A: 

Hello tracers... I have been trying for a while now to activate System.Windows.Forms.AxHost trace switches (found with .Net reflector) with no luck yet...

Did anyone succeeded in this !?

   <system.diagnostics>
      <switches>

         <!-- ActiveX to save all controls regardless of their IsDirty function return value -->
         <add name="AxAlwaysSave" value="false" />

         <!-- ActiveX switch to ignore thread models -->
         <add name="AxIgnoreTM" value="false" />

         <!-- Trace Switches:
              Off     = 0,
              Error   = 1,
              Warning = 2,
              Info    = 3,
              Verbose = 4
         -->

         <!-- ActiveX host creation Trace Level -->
         <add name="AxHost" value="4" />

         <!-- ActiveX handle tracing Trace Level -->
         <add name="AxHTrace" value="4" />

         <!-- ActiveX property tracing Trace Level-->
         <add name="AxPropTrace" value="4" />

      </switches>
   </system.diagnostics>

I am considering using reflection to get access to these private member switches in order to force their values... but this is a pretty bad way to behave and I rather would be able to change those switches in some configuration file instead...

What do you think ?

Thanks...

Didier Reis