Unable to debug WCF service message

后端 未结 12 1369
悲哀的现实
悲哀的现实 2020-12-09 15:25

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

12条回答
  •  失恋的感觉
    2020-12-09 15:38

    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:

    
        
          
          
          
          
            
          
          
        
      
    

    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.

提交回复
热议问题