Visual Studio 2005 and Single Instance applications

In these days one of the (many) tasks where I'm involved is to port a .NET Windows Form application written with the 1.1 Framework to the new .NET 2.0 and this post wants to put in evidence some little new features inside Visual Studio 2005 that permits you to save time and less coding.

One of the first things that I often found on .NET applications is to check at startup if the application is already opened and, if so, not open a new instance but activate the first.

Normally, the code to check this could be something like this (there are maybe other methods, but this is the simplest):

If Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length > 1 Then

'I have an instance already open 

End If

Visual Studio 2005 permits you to achieve the feature to have a Single Instance application without writing any lines of code. You've only to right click on your solution, choose Properties and then you'll find these new interesting checkboxes:

Why not all people know these little but really useful features? Print it on your mind...

There's only another thing to remember: if you want that VS2005 permits you to use these new automatic features, you have to check the Enable Application Framework checkbox (if it's unchecked, you have to code them manually).

Update: When writing this post I wasn't so precise. These automatic features are available only for Visual Basic .NET projects. If you open a Windows Form C# Project you can't see the checkboxes where to enable these properties. In C# for the moment you've to code all manually (always with the old manner).
Sorry for this new precisation, I use C# but the main part of my projects are VB.NET projects, so I forgot to signal this lack in C#.

Print | posted on Wednesday, April 05, 2006 11:37 AM

Comments on this post

# re: Visual Studio 2005 and Single Instance applications

Requesting Gravatar...
Only in VB?
Left by Howdy on Apr 05, 2006 12:34 PM

# re: Visual Studio 2005 and Single Instance applications

Requesting Gravatar...
Howdy, I'm sorry but I was not so precise... unfortunately C# Projects doesn't have these automatic features, they're available only for VB.NET projects.
Left by Stefano Demiliani on Apr 05, 2006 1:02 PM

# replica jewelry

Requesting Gravatar...
Howdy, I'm sorry but I was not so precise... unfortunately C# Projects
Left by replica jewelry on Apr 29, 2010 3:59 AM

# re: Visual Studio 2005 and Single Instance applications

Requesting Gravatar...
A good navigation menu will help users access necessary information quickly and easily.the eye-catching look, it will increase the performance.
Left by giochi del casinò online on May 21, 2010 11:40 AM

# re: Visual Studio 2005 and Single Instance applications

Requesting Gravatar...

Thanks for you sharing! We are the famous laptop adapter supplier and laptop battery supplier. Our main products are various rechargeable laptop battery and laptop adapter compatible with brand laptops, including IBM, COMPAQ, HP, DELL, SONY, ACER, ASUS, APPLE, and TOSHIBA and so on. Because we are the laptop battery manufacturer and laptop adapter manufacturer, we could wholesale laptop battery and wholesale laptop adapter. Our laptop battery factory and laptop adapter factory are seated in china, so we sell the laptop battery china and laptop adapter china. We also know the laptop could be called notebook, so the products we sell could be also called the notebook battery and notebook adapter. we could be called the notebook battery supplier and notebook adapter supplier. We welcome you to visit our notebook battery manufacturer and notebook adapter manufacturer.
Left by wholesale laptop adapter on May 23, 2010 2:24 PM

Your comment:

 (will show your gravatar)
 
Please add 3 and 8 and type the answer here: