简体   繁体   English

通过NetNamedPipeBinding连接到WCF服务时出现问题

[英]Problems connecting to WCF Service via NetNamedPipeBinding

I'm having trouble figuring out how to get a named pipe WCF service to work. 我在弄清楚如何使命名管道WCF服务正常工作时遇到了麻烦。 The service is in a seperate assembly from the executable. 该服务与可执行文件位于单独的程序集中。

The config looks like this: 配置看起来像这样:

  <system.serviceModel>
    <bindings>
      <netNamedPipeBinding>
        <binding name="NoSecurityIPC">
          <security mode="None" />
        </binding>
      </netNamedPipeBinding>
    </bindings>
    <client>
      <endpoint name="internal"
        address="net.pipe://localhost/"
        binding="netNamedPipeBinding"
        bindingConfiguration="NoSecurityIPC"
        contract="TimeService.ITimeService" />
    </client>
    <services>
      <service name="TimeService">
        <host>
          <baseAddresses>
            <add baseAddress="net.pipe://localhost/" />
          </baseAddresses>
        </host>            
        <endpoint name="internal"
          address="net.pipe://localhost/"
          binding="netNamedPipeBinding"
          bindingConfiguration="NoSecurityIPC"
          contract="TimeService.ITimeService" />
      </service>
    </services>
  </system.serviceModel>

I'm using a ChannelFactory to create a proxy to access the service host: 我正在使用ChannelFactory创建代理来访问服务主机:

ServiceHost h = new ServiceHost(typeof(TimeService), new Uri("net.pipe://localhost/"));
h.AddServiceEndpoint(typeof(ITimeService), new NetNamedPipeBinding("NoSecurityIPC"), "");
h.Open();

ChannelFactory<ITimeService> factory = new ChannelFactory<ITimeService>("internal");

ICpTimeService proxy = factory.CreateChannel();

using (proxy as IDisposable)
{                
    this.ds = proxy.LoadData();
}

I'm not sure what I'm doing wrong when I create the ChannelFactory. 我不确定在创建ChannelFactory时做错了什么。 It can't seem to find the "channel1" in the config. 似乎无法在配置中找到“ channel1”。 When I create my binding manually and pass it to the ChannelFactory constructor, the factory and the proxy are created but the call to the LoadData() fails (times out). 当我手动创建绑定并将其传递给ChannelFactory构造函数时,将创建工厂和代理,但是对LoadData()的调用失败(超时)。

Can anyone see what I'm doing wrong here? 有人可以在这里看到我在做什么错吗?

EDIT: I edited above app.config to make sure both endpoints have the exact same data. 编辑:我在app.config上方进行了编辑,以确保两个端点都具有完全相同的数据。 That fixed my Channelfactory problem. 这解决了我的Channelfactory问题。 however, the call to the service method as described above still times out. 但是,对上述服务方法的调用仍然超时。

I don't see the description of the problem as in the actual error message and such so it's hard to guess what your issue may be. 我没有在实际的错误消息中看到问题的描述,因此很难猜测出您的问题是什么。 Is it possible that you are attempting to run this under a non-admin account? 您是否有可能尝试在非管理员帐户下运行此程序? I'm currently having problems getting WCF with NetNamedPipeBinding as a form of IPC under non-admin user accounts on Windows 7. Perhaps you are experiencing the same problem? 我目前在使用Windows 7非管理员用户帐户下的IPC形式将NetNamedPipeBinding和WCF用作IPC时遇到问题。也许您遇到同样的问题?

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

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