"There are no more endpoints available from the endpoint mapper" First chance exception

R

rollasoc

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.
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
R

rollasoc

Windows 2000 5.00.2195 Service Pack 4

I'll look into the idea of using a mutex, since I am already doing this to
fix a slight fault where clicking many times on the exe, caused the app not
to run at all (since each instance saw another instance in the process list
and exited).

If what you say is correct I should be able to get away with simplifying my
code somewhat.

Thank you.

Rollasoc




Nicholas Paldino said:
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]
- (e-mail address removed)

rollasoc said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top