Search code examples
c#if-statementvshost32

How to determine application run under Visual Studio vshost or not?


I have an app build in Release Mode.
I want when I run app by Visual Studio (F5 key), variable is_vshost have have value true, and if I rebuild app and open it directly in Windows Explorer, it have value false. How I can do that? Thank!


Solution

  • You can check the value of

    System.Diagnostics.Process.GetCurrentProcess().ProcessName
    

    It should be devenv.exe when running from within VS.