以编程方式确定是否通过调试器或没有推出.NET WinForms应用程序 [英] Programmatically determine if .NET WinForms application launched via debugger or not
问题描述
我想知道是否有在运行时确定应用程序已通过调试或者启动已安装的应用程序版本推出了一种编程方法。我的应用程序,目前正在通过的ClickOnce部署。
I would like to know if there is a programmatic way of determining at run-time if the application was launched via the debugger or by launching an installed version of the application. My app is currently being deployed via ClickOnce.
有某些设置,我想,当应用程序运行在调试模式VS生产方式改变。
There are certain settings I would like to alter when the app is run in debug mode vs production mode.
我知道了构建配置解决方案 - 我很好奇,如果有一个编程的方式来确定此信息
I am aware of the build configurations solution -- I am curious if there is a programmatic way to determine this information
感谢
推荐答案
使用的 Debugger.IsAttached
。
这是 System.Diagnostics程序
命名空间中的一个静态方法,你可以从名字上推断,它会返回true,如果调试器附着(是否被连接的在的推出与否)。
It is a static method within the System.Diagnostics
namespace, as you can deduce from the name, it will return true if the debugger is attached (whether it was attached after launch or not).
您可以在应用程序入口点把这个(主
),以找出是否该应用程序是lauched附加一个调试器,但请记住,它可以附着在稍后的时间
You can put this in the application entry point (main
) in order to find out if the application was lauched with a debugger attached, but keep in mind that it can be attached at a later time.
这篇关于以编程方式确定是否通过调试器或没有推出.NET WinForms应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!