Tuesday, March 8, 2016

Why is WCF client configuration different when running under the VS2015 debugger?

Leave a Comment

In my WCF client code I add a message inspector (using an IEndpointBehavior).

class MyBehavior : IEndpointBehavior {     public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)     {         clientRuntime.ClientMessageInspectors.Add(new MyMessageInspector());     } }  public class MyMessageInspector : IClientMessageInspector {     public object BeforeSendRequest(ref Message request, IClientChannel channel)     {         Console.WriteLine(request.Properties.ContainsKey(HttpRequestMessageProperty.Name));     } } 

Now here comes the part I do not understand:

  • When I make a WCF call using a proxy configured to use this behavior, the following happens:

    • If the call is made from a process running inside the VS2015 debugger, True is printed to the console, meaning request.Properties["httpRequest"] is present.
    • If the call is made from a process running normally (not in the debugger), False is printed to the console.

Why is WCF configured differently when running inside/outside the VS2015 debugger? How does this happen? Is it documented anywhere?

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment