简体   繁体   English

添加WCF服务时VS2008崩溃

[英]VS2008 Crashes when adding a WCF service

I have a Console application hosting a WCF service: 我有一个托管WCF服务的控制台应用程序:

Updated this code to run off the app.config file instead of initialising it programatically 更新了此代码以运行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();

The Console app compiles and runs. 控制台应用程序将编译并运行。 svcutil runs perfectly. svcutil运行完美。

Svcutil runs against the new service code perfectly and generates the Client code and the ouput file Svcutil完美地针对新服务代码运行,并生成客户端代码和输出文件

I'm calling svcutil via the Visual Studio Command Prompt like so: svcutil.exe http://localhost:8000/ChatServer/Service 我正在通过Visual Studio命令提示符调用svcutil,如下所示:svcutil.exe http:// localhost:8000 / ChatServer / Service

It generates this output.config: 它生成此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>

Along with the bundled client code (which is in the same directory as the output file, I should add) I should be able to call the service with this: 连同捆绑的客户端代码(与输出文件位于同一目录中,我应该添加)一起,我应该能够以此调用服务:

ChatClient client = new ChatClient();

The new output from svcutil (both code and config) still throws this exception. svcutil的新输出(代码和配置)仍会引发此异常。

But it throws an exception saying: 但这引发了一个异常:

"Could not find default endpoint element that references contract 'IChat' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element." “在ServiceModel客户端配置部分中找不到引用合同'IChat'的默认终结点元素。这可能是因为没有为您的应用程序找到配置文件,或者是因为在客户端元素中找不到与该合同匹配的终结点元素。”

Interestingly, Visual Studio 2008 will crash when adding the same Service reference to a Client project. 有趣的是,将相同的Service引用添加到Client项目时,Visual Studio 2008将崩溃。

VS2008 still crashes with the updated code. VS2008仍因更新的代码而崩溃。

It will find the service, get all the operations and what not. 它将找到服务,获得所有操作,而不获得所有操作。 When I click Add, it crashes. 当我单击添加时,它崩溃。

Any one have a clue whats going on?? 任何人都知道发生了什么事吗?

Thanks in advance 提前致谢

Roberto 罗伯托

Have you tried using the configuration file setup rather than doing it programmatically? 您是否尝试过使用配置文件设置而不是通过编程方式进行设置? Then at least you'll know if it's a general settings problem or something to do with your code. 然后,至少您会知道这是一般设置问题还是与您的代码有关。 You could then roll out the code bits one by one; 然后,您可以逐一推出代码位; mex, then endpoint and see which kills it. 混合,然后终结点,看看哪个杀死它。

Does VS2008 just die without any feedback? VS2008是否会在没有任何反馈的情况下死掉? If so, check windows event log (app log) for error messages. 如果是这样,请检查Windows事件日志(应用程序日志)以获取错误消息。

One plausible cause: VS2008 + System.Core.dll 3.5 + bad NGen images can cause crashes when VS2008 tries to load either System.Core or anything that references/depends on it. 一个可能的原因:VS2008 + System.Core.dll 3.5 +错误的NGen映像可能会在VS2008尝试加载System.Core或引用/依赖于它的任何文件时导致崩溃。

You may also want to attach one VS instance to another (as debugger) to see any additional crash details. 您可能还希望将一个VS实例附加到另一个实例(作为调试器),以查看所有其他崩溃详细信息。 But I would explore the System.Core/NGen track first. 但是我将首先探讨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 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

I fixed it. 我修好了它。

I copy and pasted the system.serviceModel section from output.config into app.config after the the userSettings section and commented out the entire output.config. 我将user.Settings部分之后的system.serviceModel部分从output.config复制并粘贴到app.config中,并注释掉了整个output.config。

I also specified the name of the endpoint when inistializing ChatClient("name"). 在初始化ChatClient(“ name”)时,我还指定了端点的名称。

It seems to be working. 它似乎正在工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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