3
    <services>
  <service name="Lobby server.User Service" behavior Configuration="Service Behavior User">
    <host>
      <base Addresses>
        <add baseAddress="net.tcp://localhost:5061" />
      </base Addresses>
    </host>
    <!-- Service Endpoints -->
    <endpoint address="user" binding="netTcpBinding" binding Configuration="User Binding" contract="Lobby server.IUserService" />
    <endpoint address="user/Mex" binding="mexTcpBinding" name="ServiceBehaviorUser" contract="IMetadataExchange" />
  </service>

  <service name="Lobby server.Public Service" behavior Configuration="ServiceBehaviorPublic">
    <host>
      <base Addresses>
        <add baseAddress="net.tcp://localhost:5049" />
      </base Addresses>
    </host>
    <!-- Service Endpoints -->
    <endpoint address="public" binding="netTcpBinding" binding Configuration="Public Binding" contract="Lobby server.IPublicService" />
    <endpoint address="public/Mex" binding="mexTcpBinding" name="ServiceBehaviorPublic" contract="IMetadataExchange" />
  </service>

</services>
<behaviors>
  <service Behaviors>
    <behavior name="ServiceBehaviorUser">
      <service Debug includeExceptionDetailInFaults="true" />
      <service Metadata />
      <service Credentials useIdentityConfiguration="true">
        <service Certificate find Value="pident.cloudapp.net" store Location="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
      </service Credentials>
      <service Authorization principalPermissionMode="Always" />
    </behavior>

    <behavior name="ServiceBehaviorPublic">
      <service Debug includeExceptionDetailInFaults="true" />
      <service Metadata />
      <service Credentials>
        <service Certificate find Value="pident.cloudapp.net" store Location="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
      </service Credentials>
    </behavior>

  </service Behaviors>
</behaviors>

错误

我检查了合同和名称,但随后也发生错误并且地址为空。

错误:

在服务模型客户端配置部分中找不到名称为 NetTcpBinding_IUserService 和合同 Lobby server.IUserService 的端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

知道出了什么问题吗?任何帮助将不胜感激。谢谢

4

1 回答 1

1

没有端点名称:NetTcpBinding_IUserService

尝试为要使用的端点命名。创建 channelFactory 需要端点的名称而不是服务的名称。

用这个替换你的 nettcp 端点

<endpoint address="user" binding="netTcpBinding" binding Configuration="User Binding" 
 contract="Lobby server.IUserService" name="endpoint_NetTcp_IUserService"/>

并在您的代码中引用如下:

new DuplexChannelFactory<IUserService>(new UserHandler(), "endpoint_NetTcp_IUserService");
于 2013-04-03T06:53:17.073 回答