简体   繁体   English

WCF 使用命名管道出现“无端点监听”错误

[英]WCF error “no endpoint listening” with named pipes

I'm using WCF with .NET 3.5 I am using named pipes but keep getting the error我正在使用 WCF 和 .NET 3.5 我正在使用命名管道但不断收到错误

There was no endpoint listening at net.pipe://localhost/Test that could accept the message.在 net.pipe://localhost/Test 上没有可以接受消息的端点监听。 This is often caused by an incorrect address or SOAP action.这通常是由不正确的地址或 SOAP 操作引起的。

I followed the tutorial http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication but the problem remains.我按照教程http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication但问题仍然存在。 The endpoints on both the client and server are the same (I checked spelling etc).客户端和服务器上的端点是相同的(我检查了拼写等)。 There is no config file for this project but the config is in the code.该项目没有配置文件,但配置在代码中。

EDIT: Code (client):编辑:代码(客户端):

  ChannelFactory<ITest> pipeFactory =
    new ChannelFactory<ITest>(
    new NetNamedPipeBinding(),
    new EndpointAddress(
    "net.pipe://localhost/test"));

       ITest test= pipeFactory.CreateChannel();

            test.doStuff();

SERVER:服务器:

        serviceHost = new ServiceHost(typeof(Test), new Uri("net.pipe://localhost"));

        serviceHost.AddServiceEndpoint(typeof(ITest), new NetNamedPipeBinding(), "test");

        File.Create(@"C:\test.txt");

        serviceHost.Open();

Thanks谢谢

On the server side don't include base addresses when you create the ServiceHost instance.在服务器端创建 ServiceHost 实例时不要包含基地址。 Instead, provide the fully qualified endpoint address when you add the service endpoint:相反,在添加服务端点时提供完全限定的端点地址:

serviceHost = new ServiceHost(typeof(Test));
serviceHost.AddServiceEndpoint(typeof(ITest), new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/test"));
File.Create(@"C:\\test.txt");
serviceHost.Open();

This could be:这可能是:

  • You are running it as a windows service and the service is not running您正在将其作为 windows 服务运行并且该服务未运行
  • You are running it as a console app and there is no console.readline, so it just exists您将它作为控制台应用程序运行,并且没有 console.readline,所以它只是存在
  • You are running client and server on two different machines so that localhost is not going to the machine with the service.您在两台不同的机器上运行客户端和服务器,因此 localhost 不会使用该服务访问机器。

Another possibility to fix this root issue if you are getting an error that no net.pipe address can be found at your url (ie http://localhost:1234/MyService/etc/ ) is to make sure that the Net.Pipe Listener Adapter Windows Service is started. Another possibility to fix this root issue if you are getting an error that no net.pipe address can be found at your url (ie http://localhost:1234/MyService/etc/ ) is to make sure that the Net.Pipe Listener Adapter Windows 服务启动。 (I also started Net.Tcp Listener Adapter) (我也启动了 Net.Tcp Listener Adapter)

The service does not seem to be enabled or started in some scenarios especially when deploying out to a remote server that might not of had a lot of the development tools installed that actively use these services.在某些情况下,该服务似乎没有启用或启动,尤其是在部署到可能没有安装大量积极使用这些服务的开发工具的远程服务器时。 Starting the service fixed the issue.启动服务解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM