2011-11-16 2 views
1

Je suis en train de créer deux services Web avec WCF (VS2010). Un webservice fonctionne très bien, mais quand j'ai ajouté une deuxième webservice, alors j'obtenu l'erreur suivante:Impossible de trouver IMetadataExchange

The contract name 'IMetadataExchange' could not be found in the list of contracts implemented by the service {0}. Add a ServiceMetadataBehavior to the configuration file or to the ServiceHost directly to enable support for this contract.

La deuxième webservice est essentiellement une copie de la première. Donc je n'ai aucune idée pourquoi je reçois cette erreur et comment résoudre ce problème. Quelqu'un a-t-il une idée du problème?

Voici mon fichier App.config:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 

    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="WcfEmguCV1.Service1Behavior" name="WcfEmguCV1.EvalService"> 
     <endpoint address="" binding="wsHttpBinding" contract="WcfEmguCV1.IEvalService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfEmguCV1/Service1/" /> 
      </baseAddresses> 
     </host> 
     </service> 
     <service name="WcfEmguCV1.Image"> 
     <endpoint binding="wsHttpBinding" bindingConfiguration="" contract="WcfEmguCV1.IIMage"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfEmguCV1/Service2/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WcfEmguCV1.Service1Behavior"> 
      <!-- To avoid disclosing metadata information, 
     set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="True"/> 
      <!-- To receive exception details in faults for debugging purposes, 
     set the value below to true. Set to false before deployment 
     to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 

     <behavior name="WcfEmguCV1.Service2Behavior"> 
      <!-- To avoid disclosing metadata information, 
     set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="True"/> 
      <!-- To receive exception details in faults for debugging purposes, 
     set the value below to true. Set to false before deployment 
     to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 

     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

</configuration> 

Répondre

1

J'ai trouvé mon problème. Tout d'abord, j'ajoutais de nouvelles données à App.config via l'option "Modifier la configuration de WCF". (Faites un clic droit sur le fichier App.config et vous devriez voir cette option).

Étant donné que la première configuration de service Web était déjà par défaut, j'ai dû en ajouter une nouvelle. J'ai donc essayé d'entrer exactement les mêmes données. Mais certaines choses ne peuvent pas être ajoutées par cette méthode.

Parce que quand je pris de plus près mon fichier XML i remarqué que je manque ce pour la 2ème webservice:

<service behaviorConfiguration="WcfEmguCV1.Service1Behavior" ...> 

Tout ce que je devais faire était d'ajouter que le 2ème nœud du « service '. BehaviorConfiguration = "WcfEmguCV1.Service2Behavior"