Is it possible to check for an endpoint being available without throwing and catching an EndpointNotFoundException
I'm using code from here to do a Single Instance application, but it is very irritating to have an exception thrown at every normal startup. Exceptions should be used for exceptional conditions, not the normal operation of code.
The code in question is:
public static bool QueryPriorInstance(string[] args, string channelUri) {
try {
IPriorInstance instance = ChannelFactory<IPriorInstance>.CreateChannel(new NetNamedPipeBinding(), new EndpointAddress(channelUri));
instance.Signal(args); <- Exception is thrown here
return true;
} catch (EndpointNotFoundException) {
return false;
}
}
Thanks,
Alex