A way to determine if the IDE is running or not?

Q C#/VBin Visual Studio 2010, is there a way in the code to determine if a program is running in the IDE or not?

eg. If ProgramRunningInIDE Then MessageBox.Show exc.Message
+5
source share
2 answers

You can check if the debugger is connected:

System.Diagnostics.Debugger.IsAttached

It essentially does the same thing.

+12
source

There is an IsInDesignMode property that you can use. In some cases, this is not accurate, therefore, you can also check the UsageMode .

public static bool IsRunningInIdeContext
{
    get {
        if (DesignerProperties.IsInDesignMode)
            return true;
        return LicenseManager.UsageMode == LicenseUsageMode.Designtime;
    }
}
-3
source

All Articles