0

我使用聊天应用程序的可用 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>

提前谢谢。

4

1 回答 1

0

我相信我找到了答案。我有一个没有冒泡的异常(由于单向操作合同),这将取消该实例。一旦它关闭,就没有更多的消息起作用了。如果 MS 至少将这些异常放在输出堆栈上,那就太好了。现在我优雅地处理了错误,将消息发送给所有客户端。需要注意的一件事是,如果您使用单向合约,则不能以任何方式向客户端冒泡异常。我想我明白了,因为如果 4 个对等点有异常,你会得到哪个异常(全部 4 个?)所以我想在广播消息的对等网格中,你不能得到任何类型的回复是有道理的。

于 2010-05-01T17:05:17.750 回答