在WPF中获取应用程序模式(C#) [英] Get Application Mode in WPF (C#)

查看:96
本文介绍了在WPF中获取应用程序模式(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



WPF(C#)中是否有办法找到应用程序在Dubug模式或Release模式下运行的天气。

Hi all,

Is there is a way in WPF (C#) to find Weather the application is running in Dubug mode or Release Mode.

推荐答案

if (System.Diagnostics.Debugger.IsAttached)
  {
           // Do this
  }
  else
  {
            // Do that
  }














or

#If DEBUG Then 
    Console.WriteLine("Debug mode.") 
#Else 
    Console.WriteLine("Release mode.") 
#End If 







确保选项配置设置 - >检查项目属性中的构建定义DEBUG常量。












Make sure that the option "Configuration settings" -> "Build" "Define DEBUG constant" in the project properties is checked.

or


#If CONFIG = "Debug" Then
  ''do somtehing
#Else
  ''do something else
#EndIf


#if DEBUG

Console.WriteLine(Mode = Debug);

#else

Console.WriteLine(Mode = Release);

#endif



或者更好还是



#if DEBUG
Console.WriteLine("Mode=Debug");
#else
Console.WriteLine("Mode=Release");
#endif

OR better still

[Conditional("DEBUG")]
void PrintLog() {
    Console.WriteLine("Debug info");
}

void Test() {
    PrintLog();
}


这篇关于在WPF中获取应用程序模式(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆