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.

You might also like...

Comments

Karl Moore

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“My definition of an expert in any field is a person who knows enough about what's really going on to be scared.” - P. J. Plauger