Results 1 to 17 of 17

Thread: [2005] Single Instance Application

Threaded View

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    [2005] Single Instance Application

    I don't ask too many questions on here these days, but I figured I would ask about this and try to see if anyone maybe has some insight.

    What I am looking to do, is prevent multiple instances of my application from running. Yes I know you are probably saying "Just click the single instance application" checkbox, but unfortunatly, it is not that simple.

    There is a little known, but nasty bug in VBs application framework (which is what single instance application is part of). It is detailed here by yours truly, and is still waiting for resolution by Microsoft.

    If you don't feel like reading the bug submission, basically the problem is this:
    the Single Instance Application feature uses .NET remoting to setup a channel to listen for, detect, and handle additional instances of a given application. .NET remoting relies on TCP/IP, and certain firewalls break this functionality (mcafee and comodo to name 2, but there are more, windows onecare/windows firewall does not cause the bug, and it has all to do with how the given firewall product handles a request before access is granted)

    So anyway, since all this code wireup happens prior to the global application exception handler being hooked up, there is absolutely NO WAY to capture the socket exception that gets thrown when one of the offending firewalls blocks the remoting call. This causes a hard crash of the application. (you know the "do you want to send an error report" crash.)

    A really great VBer by the name of Bill McCarthy came up with a nice solution after seeing my bug report, however it uses features only available in .NET 3.5, and I need to resolve this for apps in .NET 2.0.

    So basically I need to try to find a workaround that simulates the single instance application framework, but does not use remoting to accomplish this. I have a feeling this issue will never be fixed by MS in .NET 2.0, and eventually fixed in a SP to 3.5 or perhaps not until whatever the next framework version is.

    The workaround needs to

    1) check for an already running instance of the app when a new instance is started up
    2) shut down the new instance in the event a first instance exists
    3) focus the already running instance (ie bring to front or maximize, etc)
    4) send any command line params from the second instance back to the first already running instance.


    So if you haven't already guessed, the thing I am stuck on at the moment is #4. All the rest are pretty simple using a few different methods.

    Does anyone have a solid way to pass data between the 2 exes without remoting?

    My application has file associations, so when a user double clicks a file that is associated with my app, it launches my app. This is why I need to handle this multiple instance thing, because if they double click a file, and my app is already open, I need to send that filename over to the already open instance so it can open that file as well.

    If you are still reading this, sorry for the long post, but I wanted to be as descriptive as possible to try to come up with a solution.
    Last edited by kleinma; Jan 22nd, 2008 at 12:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width