简体   繁体   中英

VS2008 Crashes when adding a WCF service

I have a Console application hosting a WCF service:

Updated this code to run off the app.config file instead of initialising it programatically

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 runs against the new service code perfectly and generates the Client code and the ouput file

I'm calling svcutil via the Visual Studio Command Prompt like so: svcutil.exe http://localhost:8000/ChatServer/Service

It generates this 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.

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."

Interestingly, Visual Studio 2008 will crash when adding the same Service reference to a Client project.

VS2008 still crashes with the updated code.

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? If so, check windows event log (app log) for error messages.

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.

You may also want to attach one VS instance to another (as debugger) to see any additional crash details. But I would explore the System.Core/NGen track first.

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.

I also specified the name of the endpoint when inistializing ChatClient("name").

It seems to be working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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