rollasoc,
What platform are you running this on? I think that the implementation
of GetProcessesByName is different depending on the platform (not that you
should ever know or care about it though).
However, for what you are doing, there is an easier way. I would create
a named Mutex instance, and then see if you can get a lock on it. If you
can, then you know your application is not running. If you can't get a
lock, then don't run the app. Basically, place an if block around the call
to the static Run method on the Application class, only entering if you can
obtain the Mutex.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"rollasoc" <ho*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,
When I load my application I get the the above first chance exception.
Stepping through my code it appears to be on the last line of the these
two lines
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName (current.ProcessName);
Any idea wither I need to worry about it (I'd rather it didn't except) and
\ or how to fix this.
INFO: What I'm trying to do with this code is see if the application is
running already and if it is post a
message to it's window and not run a second instance. (if it doesn't
exist I call my forms constructor).
I don't appear to get the exception if the process is already running.