Compartir a través de


Managed Debugging: Recommended Property Settings 

Certain properties should be set the same way for all managed debugging scenarios.

The following tables display recommended property settings.

Settings not listed here may vary among the different managed project types. For example, Start Action will be set differently in a Windows Forms project than in an ASP.NET project.

Configuration Properties on the Build (C# and J#) or Compile (Visual Basic) tab

Property Name Setting

Define DEBUG constant

C# and J#: Set the checkbox to checked. This enables your application to use the Debug class.

Define TRACE constant

C# and J#: Set the checkbox to checked. This enables your application to use the Trace class.

Optimize code

C#, J#, and Visual Basic: Set to false. Optimized code is harder to debug, because the generated instructions do not correspond directly to your source code. If you find your program has a bug that appears only in optimized code, you can turn this setting on, but remember that code shown in the Disassembly window is generated from optimized source that may not match what you see in the Code Editor. Other features, such as stepping, may not behave as expected, since the source code shown in the Code Editor may be different from the optimized code. To debug optimized code, you must turn Just My Code off. (See How to: Step Into Just My Code).

For more information, see Project Settings for C# and J# Debug Configurations or Project Settings for a Visual Basic Debug Configuration.

Output path

Set to bin\Debug\ in C# or J# or to bin\ in Visual Basic.

Advanced Compile Options

Click the Advanced button so you can set the advanced properties described in the following table.

Advanced Compiler Settings dialog box

Property Name Setting

Enable optimizations

Set to false for the reasons specified in the Optimize code option in the preceding table.

Generate debugging information

Select this check box to cause the /DEBUG flag to be set when compiling, which will generate information needed to facilitate debugging.

Define DEBUG constant

Select this check box to define the DEBUG constant, which enables your application to use the Debug class.

Define TRACE constant

Select this check box to define the TRACE constant, which enables your application to use the Trace class.

See Also

Other Resources

Debugging Managed Code
Debugging Preparation: C#, J#, and Visual Basic Project Types