<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 配置部分。这可能是因为没有配置文件 找到您的应用程序,或者因为没有端点元素匹配 这个名字可以在客户端元素中找到。
知道出了什么问题吗?任何帮助将不胜感激。谢谢
答案 0 :(得分: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");