首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在net.pipe没有侦听端点

在net.pipe没有侦听端点
EN

Stack Overflow用户
提问于 2014-05-07 06:19:59
回答 4查看 37K关注 0票数 6

我得到了以下错误:

在net.pipe://localhost/ServiceModelSamples/service没有能够接收消息的端点侦听。这通常是由不正确的地址或SOAP操作造成的。有关更多细节,请参见InnerException (如果存在)。

我从另一个WCF调用中调用windows服务中的WCF自托管服务,如下所示。

代码语言:javascript
复制
                   _host = new ServiceHost(typeof(CalculatorService),
            new Uri[] { new Uri("net.pipe://localhost/PINSenderService") });

        _host.AddServiceEndpoint(typeof(ICalculator),
                new NetNamedPipeBinding(),
                "");

        _host.Open();

        ChannelFactory<ICalculator> factory = new ChannelFactory<ICalculator>(
            new NetNamedPipeBinding(NetNamedPipeSecurityMode.None),
            new EndpointAddress("net.pipe://localhost/PINSenderService"));
        ICalculator proxy = factory.CreateChannel();
        proxy.SendPin(pin);
        ((IClientChannel)proxy).Close();
        factory.Close();

自托管WCF服务

代码语言:javascript
复制
 namespace PINSender
 {

    // Define a service contract.    

    public interface ICalculator
    {
        [OperationContract]
        void SendPin(string pin);
    }

    // Implement the ICalculator service contract in a service class.
    public class CalculatorService : ICalculator
    {
        // Implement the ICalculator methods.
        public void  SendPin(string pin)
        {
        }
    }

    public class CalculatorWindowsService : ServiceBase
    {
        public ServiceHost serviceHost = null;
        public CalculatorWindowsService()
        {
            // Name the Windows Service
            ServiceName = "PINSenderService";
        }

        public static void Main()
        {
            ServiceBase.Run(new CalculatorWindowsService());
        }

        // Start the Windows service.
        protected override void OnStart(string[] args)
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
            }

            // Create a ServiceHost for the CalculatorService type and 
            // provide the base address.
            serviceHost = new ServiceHost(typeof(CalculatorService));

            // Open the ServiceHostBase to create listeners and start 
            // listening for messages.
            serviceHost.Open();
        }

        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }
    }

    // Provide the ProjectInstaller class which allows 
    // the service to be installed by the Installutil.exe tool
    [RunInstaller(true)]
    public class ProjectInstaller : Installer
    {
        private ServiceProcessInstaller process;
        private ServiceInstaller service;

        public ProjectInstaller()
        {
            process = new ServiceProcessInstaller();
            process.Account = ServiceAccount.LocalSystem;
            service = new ServiceInstaller();
            service.ServiceName = "PINSenderService";
            Installers.Add(process);
            Installers.Add(service);
        }
     }

}

App.Config

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
  <service name="PINSender.CalculatorService"
           behaviorConfiguration="CalculatorServiceBehavior">
    <host>
      <baseAddresses>            
        <add baseAddress="net.pipe://localhost/PINSenderService"/>
      </baseAddresses>
    </host>

    <endpoint address=""
              binding="netNamedPipeBinding"
              contract="PINSender.ICalculator" />        
    <endpoint address="mex"
              binding="mexNamedPipeBinding"
              contract="IMetadataExchange" />                
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
      <serviceMetadata httpGetEnabled="False"  />
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
  </behaviors>
 </system.serviceModel>
</configuration>
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2014-05-07 09:07:09

  • 确保IIS配置为使用Windows Process Activation Service(WAS)
代码语言:javascript
复制
1. From the Start menu, choose Control Panel.
2. Select Programs, then Programs and Features, or in Classic view, select `Programs and Features`.
3. Click `Turn Windows Features on or off`.
4. Under Features Summary, click Add Features.
5. Expand the `Microsoft .NET Framework 3.0(or 3.5)` node and check the `Windows Communication Foundation Non-HTTP Activation feature`.

  • 确保Net.Pipe侦听器适配器服务正在运行:
代码语言:javascript
复制
1. Got to `run` & open `Services.msc`
2. Make sure `Net.Pipe Listener Adapter` service is running.

在您的App.config中,您已经在http中使用了baseAddress,尝试将其更改为net.pipe

代码语言:javascript
复制
  <baseAddresses>
    <add baseAddress="net.pipe://localhost/ServiceModelSamples/service"/>
  </baseAddresses>

有关更多详细信息,请参阅NetNamedPipeBinding

更新

您需要在bindingConfiguration中添加endpoint,例如:

代码语言:javascript
复制
<endpoint address=""
              binding="netNamedPipeBinding"
              contract="Microsoft.ServiceModel.Samples.ICalculator" 
              bindingConfiguration="Binding1" /> 

并添加实际的bindingConfiguration,如:

代码语言:javascript
复制
    <bindings>
  <!-- 
        Following is the expanded configuration section for a NetNamedPipeBinding.
        Each property is configured with the default value.
     -->
  <netNamedPipeBinding>
    <binding name="Binding1" 
             closeTimeout="00:01:00"
             openTimeout="00:01:00" 
             receiveTimeout="00:10:00" 
             sendTimeout="00:01:00"
             transactionFlow="false" 
             transferMode="Buffered" 
             transactionProtocol="OleTransactions"
             hostNameComparisonMode="StrongWildcard" 
             maxBufferPoolSize="524288"
             maxBufferSize="65536" 
             maxConnections="10" 
             maxReceivedMessageSize="65536">
      <security mode="Transport">
        <transport protectionLevel="EncryptAndSign" />
      </security>
    </binding>
  </netNamedPipeBinding>
</bindings>
票数 16
EN

Stack Overflow用户

发布于 2015-09-11 19:43:57

我也弹出了同样的错误。我在windows 8.1上运行Visual 2013。对我来说,解决方案是以管理员身份运行Visual。

票数 3
EN

Stack Overflow用户

发布于 2018-01-17 04:58:02

我还在windows 2012上运行Visual 2013,它与8.1基本相同,重新启动它作为admin也为我解决了这个问题。

希望能帮上忙!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23510184

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档