Microsoft Identity Integration Server 2003 Developer Reference

Conditional Compilation

Conditional compilation is the inclusion or exclusion of certain blocks of code depending upon the project settings. For example, if the extension creates a log file every time it is loaded, this behavior would not be desirable in the final version of the extension because it is slow and wastes system resources. Conditional compilation should be used to eliminate unnecessary code when the release version of the extension is built.

By default, Visual Studio .NET defines the DEBUG preprocessor directive in the debug configuration of a project and excludes the DEBUG directive in the release configuration of the project. This directive is very useful in excluding code used specifically for debugging when the release version of the extension is built.

The DEBUG directive is used by adding code similar to the following:

[C#]
#if(DEBUG)
	System.Diagnostics.Debug.WriteLine("debug output");
#endif
[Visual Basic .NET]
#If Debug Then
	System.Diagnostics.Debug.WriteLine("debug output")
#End If
The code between the #If and #End If is included only if the Debug directive is present.