Unable to debug WCF service message

I've got a Visual Studio 2008 solution with a WCF service, and a client.

When I run my client, and call a method from my service I get a message saying "Unable to automatically debug 'Home.Service'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the server."

I've googled around, and have tried the following.

<system.web>
   <compilation debug="true" />
</system.web>

has been added in app.config on both the client and the server.

I have also made sure that the project is being compiled in Debug mode.

What else could be causing this message?

Edit: Added more info based on feedback questions

  • It is using wsHttpBinding
  • I have set

    <serviceDebug includeExceptionDetailInFaults="true"/>
    
  • I am using

    var service = new HomeReference.HomeServiceClient();
    service.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
    

Unfortunately the error shows up the first time I call a method on my Service. I can dismiss the messagebox, and the application continues working. Any Exceptions thrown on the server at not propagated back to the client though (I assume it should?)

Answers


In my case the problem turned out to be a mismatch between security settings on client and server. I was using a custom binding like this:

<customBinding>
    <binding name="AuthorisedBinaryHttpsBinding" receiveTimeout="00:03:00" sendTimeout="00:03:00">
      <!-- this next element caused the problem: -->
      <security authenticationMode="UserNameOverTransport">
      </security>
      <binaryMessageEncoding>
        <readerQuotas maxDepth="100" maxStringContentLength="1000000"
          maxArrayLength="655360000" />
      </binaryMessageEncoding>
      <httpsTransport />
    </binding>
  </customBinding>

When I removed the security element that I've highlighted above the problem with the "Unable to automatically debug" message went away.

To solve the problem I first turned on WCF tracing. This showed me that WCF was throwing a MessageSecurityException:

Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.

That pointed me to look at the Binding settings on the client side. It turned out that I hadn't added the required security element to my custom binding there. Since I was doing this through code, I needed the following (note the 3rd line):

  var binding = new CustomBinding(
      binaryEncoding,
      SecurityBindingElement.CreateUserNameOverTransportBindingElement(),
      new HttpsTransportBindingElement { MaxReceivedMessageSize = MaxMessageSize, });

As to why Visual Studio was showing that error, I've no idea - looks to me to be a bug.


I was fighting with this exact same error for over an hour and low and behold I restarted VS2008 and it magically fixed itself. Give it a try as it might save you some time.


Need Your Help

Is it possible to get a message from an azure storage queue twice?

azure azure-storage azure-queues

I know that if a worker fails to process a message off of the queue that it will become visible again and you have to code against this (idempotent). But is it possible that a worker can dequeue a