Problem:
When adding a service in your WCF Test Client, you meet this issue says:
The contract ‘IMetadataExchange’ in client configuration does not match the name in service contract, or there is no valid method in this contract. To recover, please manually correct client configuration. Or restore to default configuration. Or check "Always regenerate config when launching services" in the Tools -> Options menu, then refresh the service.
The screen shot:
After you click “OK”, the service node will appear in the tree with the redundant “IMetadataExchange (sb)”, “IMetadataExchange (sap)”, … sections.
Cause:
Caused by BizTalk according to http://blogs.msdn.com/b/wcftoolsteamblog/archive/2008/08/28/tips-for-wcf-tools-in-vs2008-sp1.aspx.
Solution:
When you run the WCF Test Client, modify the machine.config file (located in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config)
by commenting out the <client /> section below that is nested in the <system.serviceModel> element.
<!-- <client> <endpoint address="" binding="netTcpRelayBinding" contract="IMetadataExchange" name="sb"/> <endpoint binding="sapBinding" contract="IMetadataExchange" name="sap"/> <endpoint binding="siebelBinding" contract="IMetadataExchange" name="siebel"/> <endpoint binding="sqlBinding" contract="IMetadataExchange" name="mssql"/> <endpoint binding="oracleEBSBinding" contract="IMetadataExchange" name="oracleebs"/> <endpoint binding="oracleDBBinding" contract="IMetadataExchange" name="oracledb"/> <metadata> <policyImporters> <extension type="System.ServiceModel.Channels.ContextBindingElementImporter, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/> <extension type="Microsoft.ServiceBus.Description.TcpRelayTransportBindingElementImporter, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <extension type="Microsoft.ServiceBus.Description.HttpRelayTransportBindingElementImporter, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <extension type="Microsoft.ServiceBus.Description.OnewayRelayTransportBindingElementImporter, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </policyImporters> <wsdlImporters> <extension type="System.ServiceModel.Channels.ContextBindingElementImporter, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/> <extension type="Microsoft.ServiceBus.Description.StandardRelayBindingImporter, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <extension type="Microsoft.ServiceBus.Description.TcpRelayTransportBindingElementImporter, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <extension type="Microsoft.ServiceBus.Description.HttpRelayTransportBindingElementImporter, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <extension type="Microsoft.ServiceBus.Description.OnewayRelayTransportBindingElementImporter, Microsoft.ServiceBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </wsdlImporters> </metadata> </client>-->
After that, restart your WCF Test Client you will get rid of this error.