【问题标题】:VS2008 Crashes when adding a WCF service添加 WCF 服务时 VS2008 崩溃
【发布时间】:2009-01-06 20:42:44
【问题描述】:

我有一个托管 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”的默认端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端中找不到与此合约匹配的端点元素元素。”

有趣的是,将相同的服务引用添加到客户端项目时,Visual Studio 2008 会崩溃。

VS2008 仍然会因更新代码而崩溃。

它会找到服务,得到所有的操作,什么不是。当我点击添加时,它崩溃了。

有人知道怎么回事吗??

提前致谢

罗伯托

【问题讨论】:

    标签: c# visual-studio wcf


    【解决方案1】:

    您是否尝试过使用配置文件设置而不是通过编程方式进行设置?然后至少您会知道这是一般设置问题还是与您的代码有关。然后,您可以逐个推出代码位; mex,然后终结点,看看哪个会杀死它。

    【讨论】:

    • 据我所知客户端代码正在使用配置文件。由于某种原因它不能使用它(我认为这就是异常的含义)。配置文件设置是什么意思?我是 WCF 的新手,所以我不确定。
    • 嗯好吧,与其通过代码设置服务器,不如通过WCF配置来配置服务器;然后尝试添加服务
    • Ok 添加了一个新的 WCF 服务,使用添加新项目对话框并将代码从一个服务复制粘贴到另一个服务。该服务现在运行 app.config 文件,但在客户端添加服务引用时 VS 仍然崩溃。
    【解决方案2】:

    我修好了。

    我将 output.config 中的 system.serviceModel 部分复制并粘贴到 userSettings 部分之后的 app.config 中,并注释掉了整个 output.config。

    我在初始化 ChatClient("name") 时也指定了端点的名称。

    它似乎正在工作。

    【讨论】:

      【解决方案3】:

      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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多