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!
Asked
Active
Viewed 845 times
1
NoName
- 7,940
- 13
- 56
- 108
2 Answers
2
You can check the value of
System.Diagnostics.Process.GetCurrentProcess().ProcessName
It should be devenv.exe when running from within VS.
TheEvilPenguin
- 5,634
- 1
- 26
- 47
1
In code, you can check to see if the vshosts.exe is running by looking at the CurrentDomain.FriendlyName. If it ends in ".vshosts.exe" then it's running.
bool is_vshost = false;
int i = AppDomain.CurrentDomain.FriendlyName.IndexOf(".");
string s = AppDomain.CurrentDomain.FriendlyName.Substring(i);
if (s == ".vshosts.exe")
is_vshost = true;
D.S.Reynolds
- 51
- 6