如何测试以查看网络管道服务是否在监听

Jua*_*uan 5 c# wcf named-pipes

我如何以编程方式进行测试,以查看特定的网络管道服务是否正在运行并正在侦听,所以没有出现“没有端点侦听...”异常?

因此,例如,如果我有此代码:

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();
Run Code Online (Sandbox Code Playgroud)

我想从另一个应用程序与之通信,http://localhost/something/ImListening但是在确定正在监听之前,我没有得到异常,还是该异常是测试此异常的唯一方法?

Ama*_*dan 1

聆听异常情况。这正确的做法。