HttpHostConfiguration's IServiceConfiguration support

Topics: Web Api
Feb 2, 2011 at 7:13 PM

Hi,

I have the 01.15.2011 version of the code. I am trying to use the IServiceConfiguration support on the HttpHostConfiguration class but looks like it's not working (possible bug?). I tried with both approaches, Implementing the IServiceConfiguration, and calling the AddServiceConfiguration method with the Action parameter from my constructor and neither worked, meaning that the code is not being called.

I have tracked this problem down to the WebHttpServiceHost which calls the base constructor. The base constructor is calling the overrided version of the CreateDescription, but at that point we never set the configuration to this.configuration. So this is never true:

            if (this.configuration != null)
            {
                ConfigureServiceDescription(description);
            }

WebHttpServiceHost.cs: line 108

Can you please advise on this?

Thanks in advanced.

Gustavo

 

Feb 2, 2011 at 7:52 PM

Just in case, I was able to workaround this by adding the following code at the end of the constructors with configuration parameter:

            if (this.configuration != null)
            {
                ConfigureServiceDescription(serviceDescription);
            }

This patch will not run the IServiceDescriptionFactory.CreateDescription because of the same problem as above.

Feb 18, 2011 at 12:47 PM

Good catch Gustavo - I've just come up against this issue, and then used your workaround (hacking the Microsoft.ServiceModel.WebHttp's WebHttpServiceHost constructors).

Calling base() and then doing additional setup in a constructor is just one of those bug-prone areas of dev; it's easy to reason incorrectly when reading and writing constructor code in this style.

Thanks again

ian