Build Configurations

The .NET Framework provides two classes in the System.Diagnostics namespace, Debug and Trace, which help debug your application. These classes, mentioned in Section 22.2.4.2 and described in Chapter 21, enable several debugging techniques, such as assertions, conditional error messages, and capturing errors to a log file. The Debug and Trace classes have identical methods and properties.

To use tracing or debugging, you must compile the application with the appropriate flag. To include Debug statements in a C# program, include /d:DEBUG in the compile command line or add #define DEBUG as the first line in the source code file. To include Trace statements in a C# program, include /d:TRACE in the compile command line or add #define TRACE as the first line in the source code file.

To include Debug statements in a VB.NET program, include /d:DEBUG=True in the compile command line. To include Trace statements in a VB.NET program, include /d:TRACE=True in the compile command line.

The /d command-line compile switch is the short form of /define, used to define conditional compilation symbols.

In Visual Studio .NET, these flags are set by default by the Configuration Manager, described shortly. They can also be set explicitly. In C#, this is done by right-clicking on the project in the Solution Explorer and viewing the Property Pages dialog box for the project (not to be confused with the Properties window), and then going to the Configuration Properties Build page. The Conditional Compilation Constants are listed under Code Generation. In VB.NET, the procedure is the same, except that two checkboxes are on the Configuration Properties Build page, labeled Define DEBUG constant and Define TRACE constant.

The Configuration Manager in Visual Studio .NET provides an easy way to control the build process. By default, the Configuration Manager contains two different configurations: Debug and Release. You can quickly select between the two using the Configuration Manager drop-down menu shown in Figure 22-11.

Figure 22-11. Configuration Manager drop-down menu

figs/pnwa_2211.gif

The main difference between the two configurations is that Debug statements are included only in compiled Debug builds, not Release builds, while Trace statements are included in both. All the differences between Debug and Release builds are listed in Table 22-3.

Table 22-3. Configuration build differences

Debug

Release

Debug and Trace statements included in compiled build.

Only Trace statements included in compiled build.

Not optimized for speed.

Optimized for speed.

Enables incremental build.

Disables incremental build.

C# output goes into binDebug directory.

C# output goes into binRelease directory.

VB.NET output goes into bin directory.

VB.NET output goes into bin directory.

Breakpoints enabled.

Breakpoints disabled.

Notice that in C# projects, Debug and Release builds go into separate bin directories, while in VB.NET, both go into the same bin directory. You can change the output path in either language for any specific configuration by right-clicking on the project in the Solution Explorer and selecting Properties. This opens the Property Pages dialog box, shown in Figure 22-12 for C#. The VB.NET version of the dialog box is formatted somewhat differently but is functionally the same. Any changes made to a configuration apply only to this project.

Figure 22-12. Project Property pages dialog box for C#

figs/pnwa_2212.gif

The settings for each Visual Studio .NET project are stored in a file named after the project with an extension of either .csproj or .vbproj, depending on the language, in the project directory.

You can specify which projects within a solution will be built for any specific configuration by opening the Configuration Manager dialog box, shown in Figure 22-13. This dialog box can be accessed from the configuration drop-down menu shown in Figure 22-11, from the Property Pages dialog box shown in Figure 22-12, or from the Build menu.

Figure 22-13. Configuration Manager

figs/pnwa_2213.gif

The Active Solution Configuration drop-down menu lets you select the active configuration and create new configurations or edit existing configurations. You can control which projects get built for each configuration by checking or unchecking the boxes in the Build column.

As of this writing, the only available platforms are .NET and Pocket PC (for applications using the .NET Compact Framework).


Windows Forms and the .NET Framework

Getting Started

Visual Studio .NET

Events

Windows Forms

Dialog Boxes

Controls: The Base Class

Mouse Interaction

Text and Fonts

Drawing and GDI+

Labels and Buttons

Text Controls

Other Basic Controls

TreeView and ListView

List Controls

Date and Time Controls

Custom Controls

Menus and Bars

ADO.NET

Updating ADO.NET

Exceptions and Debugging

Configuration and Deployment



Programming. NET Windows Applications
Programming .Net Windows Applications
ISBN: 0596003218
EAN: 2147483647
Year: 2003
Pages: 148

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net