Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# VS2008在添加WCF服务时崩溃_C#_Visual Studio_Wcf - Fatal编程技术网

C# VS2008在添加WCF服务时崩溃

C# VS2008在添加WCF服务时崩溃,c#,visual-studio,wcf,C#,Visual Studio,Wcf,我有一个托管WCF服务的控制台应用程序: 更新此代码以运行app.config文件,而不是以编程方式初始化它 控制台应用程序编译并运行。svcutil运行得非常好 Svcutil完美地针对新的服务代码运行,并生成客户机代码和输出文件 我通过Visual Studio命令提示符调用svcutil,如下所示:svcutil.exe 它将生成以下output.config: <?xml version="1.0" encoding="utf-8"?> <configuration

我有一个托管WCF服务的控制台应用程序:

更新此代码以运行app.config文件,而不是以编程方式初始化它

控制台应用程序编译并运行。svcutil运行得非常好

Svcutil完美地针对新的服务代码运行,并生成客户机代码和输出文件

我通过Visual Studio命令提示符调用svcutil,如下所示:svcutil.exe

它将生成以下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>
svcutil代码和配置的新输出仍然引发此异常

但它抛出了一个例外,即:

在ServiceModel客户端配置节中找不到引用协定“IChat”的默认终结点元素。这可能是因为找不到应用程序的配置文件,或者在客户端元素中找不到与此约定匹配的端点元素

有趣的是,VisualStudio2008将在向客户端项目添加相同的服务引用时崩溃

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

它将找到服务,获取所有操作,等等。当我单击Add时,它崩溃了

有人知道发生了什么吗

提前谢谢


Roberto

您是否尝试过使用配置文件设置,而不是以编程方式?然后,至少您会知道这是一个常规设置问题还是与您的代码有关。然后你可以一个接一个地推出代码位;mex,然后端点,看看是哪一个杀死了它。

VS2008会在没有任何反馈的情况下死去吗?如果是,请检查windows事件日志应用程序日志以查看错误消息

一个可能的原因是:VS2008+System.Core.dll 3.5+错误的NGen映像可能会在VS2008尝试加载System.Core或任何引用/依赖它的内容时导致崩溃

您可能还希望将一个VS实例作为调试器附加到另一个VS实例,以查看任何其他崩溃详细信息。但我会先探索System.Core/NGen轨道

我把它修好了

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

在初始化ChatClientname时,我还指定了端点的名称


就我所知,客户端代码正在使用配置文件。它只是因为某种原因不能使用它,我想这就是例外的意思。配置文件设置是什么意思?我是WCF新手,所以我不确定。啊,好吧,与其通过代码设置服务器,不如通过WCF配置配置服务器;然后尝试添加服务OK使用“添加新项”对话框添加了新的WCF服务,并将粘贴的代码从一个服务复制到另一个服务。该服务现在运行app.config文件,但在客户端添加服务引用时VS仍然崩溃。
<?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();