Compartilhar via


Error "An extension of name '' already appears in extension collection" with .Net 4.5 RC?

Do you happen to see any of the following errors when you upgrade your machine to .Net 45?

System.Configuration.ConfigurationErrorsException:An extension of name ' udpTransport ' already appears in extension collection. Extension names must be unique.

System.Configuration.ConfigurationErrorsException:An extension of name 'netHttpBinding' already appears in extension collection. Extension names must be unique.

In .NET 4.5, WCF has added UdpBinding (UDP) and NetHttpBinding (WebSockets) as standard bindings for the benefit of customers. If you happen to use any of .NET 4.0 WCF samples which help in implementing a custom UDP transport or netHttp transport binding element (old custom binding sample unrelated to WebSockets) and migrate your machine to .NET 4.5 Release candidate (RC) build, you may see an error like above. We acknowledge this as an issue and this should get automatically fixed for you in RTM build. Meanwhile here are some steps to temporarily work around this issue:

Step 1.
If you have a configuration file for your WCF client/service which fails, open and search for any binding element extension that you have configured with name “udpTransport” or “netHttpBinding”.

Step 2.
Rename it to something which is not “udpTransport” or “netHttpBinding”.

Step 3.
Restart your application / service. This should fix the problem.

BEFORE:

<system.serviceModel>   
<extensions>

<bindingElementExtensions>      
<add name="udpTransport" type="MyCustomTransport.UdpTransportElement, MyCustomTransportLibrary" />

</bindingElementExtensions>

<bindingElementExtensions>      
<add name="netHttpBinding" type="MyCustomTransport.NetHttpTransport, MyCustomTransportLibrary "/>

</bindingElementExtensions>
  

</system.serviceModel>

AFTER:

<system.serviceModel>  
<extensions>

<bindingElementExtensions>      
<add name="myCustomUdpTransport" type="MyCustomTransport.UdpTransportElement, MyCustomTransportLibrary" />

</bindingElementExtensions>

     
<bindingElementExtensions>

         <add name="myCustomNetHttpBinding" type="MyCustomTransport.NetHttpTransport, MyCustomTransportLibrary" />
</bindingElementExtensions>
  

</system.serviceModel>

Thanks.