Have you ever wondered how to determine if your application is running as a standalone app or from within the Visual Studio IDE? I needed to do that today, and it took some scrounging around, but this is what I came up with.

One caveat exists - This technique can be rendered useless by going to the project's Properties page, clicking on the Debug tab, and then unchecking the check box that reads "Enable the Visual Studio Hosting Process". My advice - don't uncheck that box.

Share

About the Author

I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.

My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.

Any time you have an app that takes command line arguments, well, you can put them in the project, but sometimes it's handier to make the program ask for them (or handier to hardcode them or have the program auto-deduce them) especially if they are long or change frequently. This is to increase testing productivity. If you never had to do that this would seem stupid. But if you are manually testing 100 times (really not verify much except for trivial apps) and it takes you 30sec longer to update project properties than to enter a GUI or have the program figure them out, you're losing an hour, so if it takes 10 minues for the gui, that's 40 minutes of youtube time you've gained.

If you disable it, you lose edit-and-continue. That has saved me 100s of hours, not only recompiling, but not having to re-load/enter the case into the LOB apps I work on, I can re-test and just fly on. Wonderful productivity enhancer.