2

I have a WCF service (.NET 3.5) application running at http://example.com; its web.config is configured for JSONP encoding:

<extensions>
  <bindingElementExtensions>
    <add name="jsonpMessageEncoding" type="My.SharePoint.WebServices.JsonpBindingExtension, My.SharePoint.WebServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  </bindingElementExtensions>
</extensions>

where class My.SharePoint.WebServices.JsonpBindingExtension is a part of the aplication.

Now, we are deploying another WCF application at http://example.com/other-services/ and here is where I have a problem - when I try to call this service I get an error that it can't load My.SharePoint.WebServices assembly, even though I am not using it in this other application. It looks like web.config of the top application is merged with this web.config.

Is there any way to remove/unregister jsonpMessageEncoding in this sub-application?

I was hoping to do something like:

<extensions>
  <bindingElementExtensions>
    <remove name="jsonpMessageEncoding"/>
  </bindingElementExtensions>
</extensions>

But there is no remove for this config section.

Any ideas?

Andrey
  • 20,487
  • 26
  • 108
  • 176

1 Answers1

0

If your new application is deployed directly under the first application web configs are indeed merged. Unfortunately extensions cannot be removed - even related configuration class doesn't support anything except add method the reason is that call to add will be processed first and the type will be already parsed prior to reaching your expected remove.

As the workaround (untested) you can try to use location element in your root application web.config and to define extension only for root application.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670