Sunday, March 20, 2011

WCF Error: The contract name ‘IMetadataExchange’ could not be found in the list of contracts implemented by the service

This is the most common error almost everyone receives when starts learning WCF and mostly because you have overlooked the configuration. It is easy to miss the typo mistake and specially when it is just matter of lower or upper case of a single character. We, developers, are normally used to capitalize the “D” of the “Data” and this is what we do with “IMetadataExchange” and type “IMetaDataExchange”. Remember configuration parser is case sensitive and it treats “IMetadataExchange” and “IMetaDataExchange” differently. WCF complains this typo mistake in this fashion.spelled wrong

This error clearly states that it is unable to find the contract. Now even after correcting the mistake you still can face another yellow screen of error

metadataexchangeerror

This happens because

  • You have not defined serviceMetadata behavior. Go to configuration file and add following configuration sample.
    <behaviors>
    <serviceBehaviors>
    <behavior name="default">
    <serviceMetadata httpGetEnabled="true" />
    </behavior>
    </serviceBehaviors>
    </behaviors>



  • You have defined the service behavior but have not set the service behavior configuration name. Set the behaviorConfiguration attribute of the service to the name of the service behavior you defined.
<services>
<service name="Service" behaviorConfiguration ="default">

6 comments:

  1. browse around this website Dolabuy Loewe published here discover this info here published here review

    ReplyDelete