Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

Does Your App Know Where it's Running

4.78/5 (8 votes)
3 Feb 2011CPOL 10.6K  
I use the following to insert pauses into console apps when they are vs hosted. In fact it's the final lines in my standard template for a console app to ensure that the console stays visible until I dismiss it.if (AppDomain.CurrentDomain.FriendlyName.EndsWith(vshost.exe,...
I use the following to insert pauses into console apps when they are vs hosted. In fact it's the final lines in my standard template for a console app to ensure that the console stays visible until I dismiss it.
C#
if (AppDomain.CurrentDomain.FriendlyName.EndsWith("vshost.exe", StringComparison.OrdinalIgnoreCase)) {
  // you are vs hosted
  Console.WriteLine("Press a key to continue...");
  Console.ReadLine();
}


Alan.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)