2010-05-01 28 views
0

我轉換了一個VB .Net 3.5應用程序以使用對等WCF使用聊天應用程序的可用Microsoft示例。我確保我複製了示例的app.config文件(修改了我的應用程序的名稱),添加了適當的引用。我遵循了所有的教程,並在我的應用程序代碼中添加了適當的標籤和結構。一切都運行沒有任何錯誤,但客戶端只能從他們自己而不是從其他客戶端收到消息。示例聊天應用程序對多個客戶端運行得很好。我能找到的唯一區別是示例服務器的目標是框架2.0,但我認爲這是錯誤的,它至少在3.0中構建它,否則System.ServiceModel引用將會中斷。是否有必須註冊樣本是在幕後進行還是樣本是特殊項目類型?我很困惑。我的下一步是將我的應用程序中的所有類和邏輯複製到示例應用程序,但這可能是很多工作。
這裏是我的客戶端的App.config:使用Peer Chat應用程序作爲示例的WCF應用程序不起作用

 <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> 

感謝。

+0

http://asp-net-csharp-vb.blogspot.com/2009/09/wcf-chat-sample.html – Micle 2011-05-17 20:34:39

回答

0

我相信我想出了答案。我有一個例外,那就是沒有冒泡(由於單向操作合同),並且會取消那個實例。一旦失敗,沒有更多的消息會起作用。這將是很好,MS會至少把這些例外放在輸出堆棧。現在我優雅地處理了這些錯誤,將消息發送給所有客戶端。需要注意的一點是,如果您使用的是單向協議,則無法以任何方式將異常情況發送給客戶端。我想我明白了,因爲如果4個同伴有例外,你會得到哪個例外(所有4個?)所以我想這是有道理的,在一個對等網格中廣播消息,你不能得到任何形式的答覆。

相關問題