views:

850

answers:

4

Hi guys, 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

A: 

I had the same issue once. Had to re-install my system.

MartinHN
Tried it on two different machines. I don't think a re-install is it.
Roberto Bonini
A: 

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.

blowdart
As far as i know the client code is using the config file. It just can't use it for some reason (I think this is what the exception means). And what do you mean by configuration file setup? I'm new to WCF so i'm not sure.
Roberto Bonini
Ah ok, rather than setup the server via code, configure the server via WCF configuration; then try to add the service
blowdart
Ok, will try that. Thanks.
Roberto Bonini
Ok Added a New WCF Service using the Add New Item Dialog box and copy pasted the code from one service to the other.The service runs off the app.config file now, but VS still crashes when adding a Service Reference on the Client side.
Roberto Bonini
A: 

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

KristoferA - Huagati.com
A: 

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.

Roberto Bonini