Alex Mueller on Software and Technology 
Wednesday, June 08, 2005

What is wrong with my preprocessor directives in my web application? They work fine in another applications I have, but not in my current one. The logic in my directive is grayed out and is not being executed in debug mode.

If you have ever come across this situation, here is what you can do to resolve it. Two methods I used are to manually add "DEBUG" in your Visual Studio project's properties, and the other way is to manually edit the project file (*.csproj, *.vbproj, or whatever other language you use). I realize in the picture presented that #else is not necessary, but I show it for support.

  1. In Visual Studio .Net, access your project's property pages by right clicking the project, then go to "Properties." Next, navigate to your Configuration Properties for your Debug configuration. In the Build section, there is a "Conditional Compilation Constants." Add "DEBUG" without the quotations to this entry. Click "OK" to exit the properties dialog. Your DEBUG code should now work.

  2. Navigate to your project's project file on the file system and open it for editing. In your Build/Settings section, modify your Debug Config section so "DefineConstants" has "DEBUG" in it. It should look like the following, unless you have other directives set.
    <Config
        Name = "Debug"
        AllowUnsafeBlocks = "false"
        BaseAddress = "285212672"
        CheckForOverflowUnderflow = "false"
        ConfigurationOverrideFile = ""
        DefineConstants = "DEBUG"
        DocumentationFile = ""
        DebugSymbols = "true"
        FileAlignment = "4096"
        IncrementalBuild = "true"
        NoStdLib = "false"
        NoWarn = ""
        Optimize = "false"
        OutputPath = "bin\"
        RegisterForComInterop = "false"
        RemoveIntegerChecks = "false"
        TreatWarningsAsErrors = "false"
        WarningLevel = "4"
    />

Wednesday, June 08, 2005 3:11:58 PM (Mountain Standard Time, UTC-07:00) | Comments [0] | #
MuellerDesigns.net
Search
On This Page
PowerShell Documentation
Automate Daily Tasks with PowerShell
SketchPath XPath Editor
Software Testing - Revisited
Architecting Buildings and Software
NBCOlympics.com with Silverlight
Marker Interfaces and C# Attributes
The Phone Screen
Working with ASP.NET MVC and MvcContrib
Thanks to BDD
Twitter
The Opposite of a Singleton?
Removing Duplicate Code in Functions
Add Vista Themes to Longhorn
Changing File Ownership In Vista and Longhorn
Most Popular
JavaScript ReplaceAll Functionality
What is polymorphism?
What is composition?
Sorting with IComparable and IComparer
Applying the Observer Pattern in ASP.NET
MVP in ASP.NET
What is abstraction?
What is encapsulation?
What is a class?
What is inheritance?
Authentication in ASP.NET
Calendar Controls
XPathNavigator.CheckValidity new for 2.0
SQL Server 2005 Connection Issues
Auto-attach to process '[####] aspnet_wp.exe' on m...
What is an object?
FreeTextBox
VMWare and VPC
An Example of Reflection using C#
Caring for the Team
Archive
Links
Categories
My Local Blog Map
Blogroll
About
Powered by:

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2009
MuellerDesigns.net

Sign In

Help Those In Need
The Hunger Site
Ronald McDonald House Charities (RMHC) of Western Washington & Alaska