[英]VS2008 Crashes when adding a WCF service
我有一個托管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>
連同捆綁的客戶端代碼(與輸出文件位於同一目錄中,我應該添加)一起,我應該能夠以此調用服務:
ChatClient client = new ChatClient();
svcutil的新輸出(代碼和配置)仍會引發此異常。
但這引發了一個異常:
“在ServiceModel客戶端配置部分中找不到引用合同'IChat'的默認終結點元素。這可能是因為沒有為您的應用程序找到配置文件,或者是因為在客戶端元素中找不到與該合同匹配的終結點元素。”
有趣的是,將相同的Service引用添加到Client項目時,Visual Studio 2008將崩潰。
VS2008仍因更新的代碼而崩潰。
它將找到服務,獲得所有操作,而不獲得所有操作。 當我單擊添加時,它崩潰。
任何人都知道發生了什么事嗎?
提前致謝
羅伯托
您是否嘗試過使用配置文件設置而不是通過編程方式進行設置? 然后,至少您會知道這是一般設置問題還是與您的代碼有關。 然后,您可以逐一推出代碼位; 混合,然后終結點,看看哪個殺死它。
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
我修好了它。
我將user.Settings部分之后的system.serviceModel部分從output.config復制並粘貼到app.config中,並注釋掉了整個output.config。
在初始化ChatClient(“ name”)時,我還指定了端點的名稱。
它似乎正在工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.