相关疑难解决方法(0)

C#if/then指令用于debug和release

在解决方案属性中,我将Configuration设置为"release",用​​于我唯一的项目.

在主程序的开头,我有这个代码,它显示"Mode = Debug".我也在最顶端有这两行:

#define DEBUG 
#define RELEASE
Run Code Online (Sandbox Code Playgroud)

我在测试正确的变量吗?

#if (DEBUG)
            Console.WriteLine("Mode=Debug"); 
#elif (RELEASE)
            Console.WriteLine("Mode=Release"); 
#endif
Run Code Online (Sandbox Code Playgroud)

我的目标是根据调试版本和发布模式为变量设置不同的默认值.

c# debugging release compiler-directives

401
推荐指数
12
解决办法
32万
查看次数

在运行时期间检查asp.net Web应用程序是否处于调试模式的首选方法?

在编译期间,我可以做一个检查

#if DEBUG
    Log("something");
#endif
Run Code Online (Sandbox Code Playgroud)

但是debug="false",在运行时期间检查是否在Web.config中设置是首选的是什么?

c# asp.net web-config

40
推荐指数
2
解决办法
2万
查看次数