我使用聊天应用程序的可用 Microsoft 示例将 VB .Net 3.5 应用程序转换为使用点对点 WCF。我确保我复制了示例的 app.config 文件(修改了我的应用程序的名称),添加了适当的引用。我遵循了所有教程,并在我的应用程序代码中添加了适当的标签和结构。一切都运行没有任何错误,但客户端只从他们自己而不是从其他客户端获取消息。示例聊天应用程序在多个客户端上运行得很好。我能找到的唯一区别是示例中的服务器以框架 2.0 为目标,但我认为这是错误的,它至少在 3.0 中构建它,否则 System.ServiceModel 引用会中断。样本在幕后执行的操作是否需要注册,或者样本是否是特殊项目类型?我很困惑。我的下一步是将我的所有类和逻辑从我的应用程序复制到示例应用程序,但这可能需要大量工作。
这是我的客户端 App.config:
<client><endpoint name="thldmEndPoint"
address="net.p2p://thldmMesh/thldmServer"
binding="netPeerTcpBinding"
bindingConfiguration="PeerTcpConfig"
contract="THLDM_Client.IGameService"></endpoint></client>
<bindings><netPeerTcpBinding>
<binding name="PeerTcpConfig" port="0">
<security mode="None"></security>
<resolver mode="Custom">
<custom address="net.tcp://localhost/thldmServer" binding="netTcpBinding"
bindingConfiguration="TcpConfig"></custom>
</resolver>
</binding></netPeerTcpBinding>
<netTcpBinding>
<binding name="TcpConfig">
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
这是我的服务器 App.config:
<services>
<service name="System.ServiceModel.PeerResolvers.CustomPeerResolverService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/thldmServer"/>
</baseAddresses>
</host>
<endpoint address="net.tcp://localhost/thldmServer"
binding="netTcpBinding"
bindingConfiguration="TcpConfig"
contract="System.ServiceModel.PeerResolvers.IPeerResolverContract">
</endpoint>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="TcpConfig">
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
提前谢谢。