Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / November 2007

Tip: Looking for answers? Try searching our database.

Best practice for single instance and file associations?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julie - 26 Nov 2007 20:56 GMT
What is the best practice for a (.Net 2.0) application that is limited
to a single instance and has file associations?

There appear to be two methods for communicating verbs between Explorer
and an application: command line and DDE.

Going w/ the command line route, if there is already an instance of my
application running, I need to detect that, and then communicate the
command line to the 'main' instance using ?  Remoting, I guess?

Using the DDE route: this seems like the more standard route, however
I'm not seeing anything that immediately supports this in the .Net
Framework.  ?  There has to be something, as this is Windows standard
behavior since when...

Anyone have any thoughts/comments/pointers/suggestions on what is
best/standard practice for handling file association verb requests in .Net?

Thanks!
Jeffrey Tan[MSFT] - 27 Nov 2007 02:41 GMT
Hi Julie,

Normally, the easiest way of implementing single instance application is
using global named mutex. The principle of this approach leverages the fact
that mutex kernel object can have a global name associated with it.
Multiple processes can see the same registered name. So if the first
process has created the name, the second instance(process)'s creation will
fail.

.Net has the build-in support for the named mutex, so it is easy to use
this approach in .Net:
"Ensuring that only a single instance of a .NET application is running"
http://www.ai.uga.edu/mc/SingleInstance.html

The remind requirement is passing the command line argument of the second
instance to the first running instance. You can leverage any type of
inter-process communication technologies to get this done, such as named
pipe, socket, Remoting etc.. Sure, since .Net only has native support for
.Net Remoting, it is recommended to use it. The article below demonstrated
this:
"Single Instance Application, Passing Command Line Arguments"
http://www.codeproject.com/cs/threads/SingletonApp.asp

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Julie - 29 Nov 2007 00:27 GMT
> Hi Julie,
>
[quoted text clipped - 6 lines]
> "Single Instance Application, Passing Command Line Arguments"
> http://www.codeproject.com/cs/threads/SingletonApp.asp

Perfect -- thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.