I have an ASP.NET 3.5 web application. For the application:
- Configuration set to "DEBUG;
- "Define DEBUG constant" checkbox is checked for "DEBUG" configuration;
- web.config file contains 'true' as v开发者_开发百科alue for 'debug' attribute of 'compilation' node.
Nevertheless to everything the following code:
#if ( _DEBUG )
const bool DebugMode = true;
#else
const bool DebugMode = false;
#endif
string strSettings = string.Concat("(DebugMode: ", DebugMode, ")");
put "DebugMode: False" into result string. In the same time I can't connect to the application with VisualStudio in debug mode...
Question:
how can I get real value of debugging mode?
Is this C#? The constant is DEBUG
, not _DEBUG
.
Do you compile the website as a Web Application?
Your _DEBUG
constant for Compile Pre-Processor directives are set by Visual Studio and passed to the compiler like this
csc /define:_DEBUG
But when you access the website its normally not compiled by Visual Studio, but the asp_net compiler and it only looks at the debug-attribute of the compilation section. You can check the value of this attribute at runtime using
HttpContext.Current.IsDebuggingEnabled
If you REALLY need Symbols defined in your webpages, you can pass /define arguments to the compiler by specifying it in web.config
<configuration>
<system.web>
<compilation debug="true">
<compilers>
<compiler language="C#;Csharp" compilerOptions="d:_DEBUG"/>
</compilers>
</compilation>
</system.web>
</configuration>
精彩评论