2009-01-06 58 views
0

時,我有一個託管WCF服務的控制檯應用程序VS2008崩潰添加WCF服務

更新此代碼運行脫app.config文件,而不是初始化它編程

Uri baseAddress = new Uri("http://localhost:8000/ChatServer/Service"); 
     ServiceHost myHost = new ServiceHost(typeof(ClientServerChat.ChatServer), baseAddress); 

      myHost.AddServiceEndpoint(typeof(IChat), new WSHttpBinding(), "ChatService"); 
      ServiceMetadataBehavior mb = new ServiceMetadataBehavior(); 
      ServiceBehaviorAttribute attrib = (ServiceBehaviorAttribute)myHost.Description.Behaviors[0]; 
      attrib.IncludeExceptionDetailInFaults = true; 
      mb.HttpGetEnabled = true; 
      myHost.Description.Behaviors.Add(mb); 

      myHost.Open(); 

的控制檯應用程序編譯並運行。 svcutil完美運行。

SvcUtil工具違背了新的服務代碼完美,生成客戶端代碼和輸出中的文件

我打電話通過Visual Studio命令提示符SvcUtil工具,像這樣:svcutil.exe的http://localhost:8000/ChatServer/Service

它生成這個output.config:

<?xml version="1.0" encoding="utf-8"?> 
    <configuration> 
    <system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_IChat" closeTimeout="00:01:00" openTimeout="00:01:00" 
     receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" 
     transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
     messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
     allowCookies="false"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
      enabled="false" /> 
      <security mode="Message"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" 
      realm="" /> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" 
      algorithmSuite="Default" establishSecurityContext="true" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8000/ChatServer/Service/ChatService" 
     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IChat" 
     contract="IChat" name="WSHttpBinding_IChat"> 
     <identity> 
      <userPrincipalName value="Bedroom-PC\Roberto" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 
</configuration> 

隨着捆綁的客戶端代碼(這是在與t他輸出文件,我要補充),我應該能夠與此調用服務:

ChatClient client = new ChatClient(); 

從SvcUtil工具(代碼和配置新的輸出)仍然拋出該異常。

但它拋出一個異常說:

「找不到,在ServiceModel客戶端配置單元參考合同‘的iChat’默認終結點元素這可能是因爲沒有配置文件找到您的應用程序,或者因爲在客戶端元素中找不到匹配此合同的端點元素。「

有趣的是,在將相同的服務引用添加到客戶端項目時,Visual Studio 2008會崩潰。

VS2008仍然與更新的代碼崩潰。

它會找到服務,得到所有的操作,不能。當我點擊添加時,它崩潰。

任何人都有線索怎麼回事?

在此先感謝

羅伯託

回答

0

我固定它。

在userSettings部分之後,我將output.config中的system.serviceModel節複製並粘貼到app.config中,並將整個output.config註釋掉。

我還在初始化ChatClient(「名稱」)時指定了端點的名稱。

它似乎在工作。

0

您是否嘗試過使用配置文件的設置,而不是編程方式這樣做呢?那麼至少你會知道這是一個常規設置問題還是與你的代碼有關。然後您可以逐個推出代碼位; mex,然後終點並查看哪個殺死了它。

+0

據我所知客戶端代碼使用配置文件。它出於某種原因不能使用它(我認爲這是例外的意思)。你的配置文件設置是什麼意思?我是WCF新手,所以我不確定。 – 2009-01-06 22:49:45

0

是否VS2008死亡沒有任何反饋?如果是這樣,請檢查Windows事件日誌(應用程序日誌)中的錯誤消息。

一個可能的原因:VS2008 + System.Core.dll 3.5 +壞NGen圖像可能會導致崩潰,當VS2008試圖加載任何System.Core或任何引用/依賴於它。

您可能還想將一個VS實例附加到另一個(作爲調試器)以查看任何其他崩潰詳細信息。但我會首先探索System.Core/NGen的軌跡。

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=341658 https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=337149 https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=330302 https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=330903