O'Reilly logo

Application Development Using Visual Basic® and .NET by Dana L. Wyatt, Peter Thorsteinson, Robert J. Oberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enabling or Disabling Switches

You can use settings in your application configuration file to enable or disable a switch at startup. This can also be done programmatically.

Configuration File Switch Settings

You can set the switch's initial setting in the application's configuration file.

<?xml version="1.0"?>
<configuration>
    <system.diagnostics>
        <trace indentsize="15" />
            <switches>
                <add name="DebugSwitch" value = "1" />
							<add name="TraceSwitch" value = "2" />
            </switches>
    </system.diagnostics>
</configuration>

If no values are found, the initial value of the DebugSwitch's Enabled property is set to false and the TraceSwitch's Level property is set to off.

Programmatic Switch Settings

The Enabled property of the DebugSwitch can be set to true ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required