繁体   English   中英

添加WCF服务时VS2008崩溃

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM