Is your code running in development mode?

I’ve had to determine the answer to this question in a number of
different applications that I’ve worked on.  Most recently it was
Visual Studio .Net 2003.

What I ended up doing was creating a simple function called RunningInDevMode and gave it this one line of code:

Return System.Diagnostics.Debugger.IsAttached()

It has been working wonderfully and is better than the VB6 hack I used:

On Error GoTo EH:

    Debug.Print 1/0

    RunningInDevMode = False

    Exit Function


    RunningInDevMode = True