Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到IMetadataExchange_C#_Wcf - Fatal编程技术网

C# 找不到IMetadataExchange

C# 找不到IMetadataExchange,c#,wcf,C#,Wcf,我正在尝试使用WCF(VS2010)构建两个Web服务。 一个Web服务运行正常,但当我添加第二个Web服务时,出现以下错误: 在列表中找不到合同名称“IMetadataExchange” 由服务{0}实现的合同的数量。添加 ServiceMetadataBehavior到配置文件或 ServiceHost直接启用对此合同的支持 第二个Web服务基本上是第一个Web服务的副本。所以我不知道为什么会出现这个错误以及如何解决这个问题。有人知道问题出在哪里吗 这是我的App.config文件: <

我正在尝试使用WCF(VS2010)构建两个Web服务。 一个Web服务运行正常,但当我添加第二个Web服务时,出现以下错误:

在列表中找不到合同名称“IMetadataExchange” 由服务{0}实现的合同的数量。添加 ServiceMetadataBehavior到配置文件或 ServiceHost直接启用对此合同的支持

第二个Web服务基本上是第一个Web服务的副本。所以我不知道为什么会出现这个错误以及如何解决这个问题。有人知道问题出在哪里吗

这是我的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>

我发现了我的问题。首先,我通过“编辑WCF配置”选项向App.config添加新数据。(右键单击App.config文件,您应该会看到该选项)

由于默认情况下第一个webservice配置已经存在,因此我必须添加一个新配置。所以我试着输入完全相同的数据。但有些东西不能通过这种方法添加

因为当我仔细查看我的XML文件时,我注意到第二个Web服务缺少以下内容:

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

所以我所要做的就是把它添加到“服务”的第二个节点


behaviorConfiguration=“WcfEmguCV1.Service2Behavior”

我发现了问题。首先,我通过“编辑WCF配置”选项向App.config添加新数据。(右键单击App.config文件,您应该会看到该选项)

由于默认情况下第一个webservice配置已经存在,因此我必须添加一个新配置。所以我试着输入完全相同的数据。但有些东西不能通过这种方法添加

因为当我仔细查看我的XML文件时,我注意到第二个Web服务缺少以下内容:

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

所以我所要做的就是把它添加到“服务”的第二个节点

行为配置=“WcfEmguCV1.Service2Behavior”