ProblemYour application needs to respond one way if it is running in the Visual Studio development environment and another way if it is running as a standalone application. For instance, you might want to issue a Stop statement on errors when in the debugging environment but log the errors to a file when running as a standalone application. SolutionThere are a few different ways to determine the running environment of your application, but the simplest is to examine the System.Diagnostics.Debugger. IsAttached flag. If this property is TRue, your application is running in the development environment. DiscussionThe IsAttached property indicates TRue whenever your application is running in a debugger that properly sets the underlying value of this flag. That means that if the flag is true, the program may be running in some environment other than Visual Studio. But if your program is running in some nonVisual Studio debugger, there are probably bigger issues of concern. |