How can I test programmatically to see if a particular net pipe service is running and listening, so I don't get a "There was no endpoint listening at..." exception?
So for instance if I have this code:
Uri baseAddress = new Uri("http://localhost/something");
var _ServiceHost = new ServiceHost(typeof(Automation), new Uri[] { baseAddress });
NetNamedPipeBinding nnpb = new NetNamedPipeBinding();
_ServiceHost.AddServiceEndpoint(typeof(IAutomation), nnpb, "ImListening");
_ServiceHost.Open();
I want from another application communicate with http://localhost/something/ImListening
but before I want to make sure is listening so I don't get an exception, or is the exception the only way to test this?
Listen for the exception. That is the proper way to do it.
Exceptions exists for a reason, I would just handle the exception, as long a you handle it the user wont get a cryptic error message, which I guess is what you are trying to avoid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With