Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在C#/VBin 中Visual Studio 2010,代码中有没有办法确定程序当前是否在 IDE 中运行?
C#/VB
Visual Studio 2010
eg. If ProgramRunningInIDE Then MessageBox.Show exc.Message
您可以检查调试器是否附加:
System.Diagnostics.Debugger.IsAttached
这基本上做同样的事情。
您可以使用IsInDesignMode属性。但是,在某些情况下它并不准确,因此您可能还需要检查UsageMode。
public static bool IsRunningInIdeContext { get { if (DesignerProperties.IsInDesignMode) return true; return LicenseManager.UsageMode == LicenseUsageMode.Designtime; } }