Click here to Skip to main content
15,884,836 members
Articles / Desktop Programming / Windows Forms
Alternative
Tip/Trick

Does Your App Know Where it's Running

Rate me:
Please Sign up or sign in to vote.
4.78/5 (8 votes)
3 Feb 2011CPOL 9.6K   1   3
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)


Written By
Engineer
United Kingdom United Kingdom
There were these two guys at work who programmed a product costing programme on the new Wang (10Meg Winchester). I looked at their spaghetti and thought uhh, what's going on there. That was while ago, as I see that the spiral bound Wang Professional Computer Series "Basic Language Guide" Third Edition, which I've just pulled off the bookshelf, was published in 1985.

Shortly after that "the corporation" upgraded to the heavenly Amstrad 1512's (20Meg). Paul and I cracked the password file and I was really keen on creating a key logger but decided that I wanted to keep my job instead.

Way before all of this my cousin had a computer and although I can't remember what make it was, it seems that his programming pinnacle was making the lights on it's front panel flash on and off. At the time I was more interested in Lego. Happy days.

Back to the Wang, if that not too rude a phrase, I remember that our IT professional programmed F1 to enter the mainframe password because no one knew what it was!

Most embarrassing computer moment... Having to admit that it was me who had typed del c:\*.*

Comments and Discussions

 
GeneralMy vote of 1 Pin
justpower25-Oct-13 16:33
justpower25-Oct-13 16:33 
nice
GeneralNice! Pin
Dr.Walt Fair, PE15-Aug-11 15:20
professionalDr.Walt Fair, PE15-Aug-11 15:20 
GeneralThat's deserving of its own tip. Pin
#realJSOP3-Feb-11 21:15
mve#realJSOP3-Feb-11 21:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.