Library code snippets

Are You Running in the IDE?

Previous versions of Visual Basic made it easy to figure out whether you were running your application through the IDE (Integrated Development Environment). It simply allowed you to check which “mode” your application was in. VB.NET, however, isn’t quite as easy-going.

The most common method of figuring out whether the application is running in the .NET IDE is to check the System.Diagnostics.Debugger.IsAttached property to determine whether if a debugger is attached to the currently executing code. If so, you can safely assume your code is running from within the IDE.

If you’re designing your own controls, you might also run into the situation where your code is running in design mode—while you only want it to execute during ‘full’ runtime. In this situation, simply check the DesignMode property of your component (that is, from inside your control: Me.DesignMode). If it returns True, you’re running in the IDE—so cut your code short.

Simple solutions to common questions, and definitely worth remembering.

Comments

  1. 13 Jan 2004 at 00:38
    You can also use conditional compilation constants to test if you are debug the app.

    #If Debug = True Then
       'Code for debuging
    #Else[/courier new]
       'Code for the real thing
    #End If
  2. 01 Jan 1999 at 00:00

    This thread is for discussions of Are You Running in the IDE?.

Leave a comment

Sign in or Join us (it's free).

Karl Moore

Related podcasts

  • xpert to Expert: Inside Concurrent Basic (CB)

    "Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...

Want to stay in touch with what's going on? Follow us on twitter!