【问题标题】:IMetaDataExchange could not be found in the list of contracts implemented by the service在服务实施的合同列表中找不到 IMetaDataExchange
【发布时间】:2013-10-07 03:08:28
【问题描述】:

我已在网上搜索此错误的解决方法,但我发现的一切都表明我所拥有的一切都是正确的。

也许有人可以看看并发现一个我看不到的明显错误。

我有一个 Windows 服务,托管两个合同:

  1. IConfigurationService
  2. IConfigurationAdminService

管理服务继承自标准服务,因为我希望两个合约都实现基本方法。

问题是我可以很好地托管服务,直到我尝试添加 MEX。

然后我得到以下异常:

在服务“ConfigurationWCFService”实施的合同列表中找不到合同名称“IMetaDataExchange”。

这是我的配置,一切都是通过config配置的,没有通过代码完成。

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="tcpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="serviceBehavior" name="BrightsideGroup.Repa.Configuration.ConfigurationWCFService">
        <endpoint address="ConfigurationService" binding="netTcpBinding"
          bindingConfiguration="tcpBinding" name="tcpConfiguration" contract="BrightsideGroup.Repa.Configuration.IConfigurationWCFService" />
        <endpoint binding="mexHttpBinding" address="mex" name="mex" contract="IMetaDataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://GD01316:9123/Repa" />
            <add baseAddress="http://GD01316:8123/Repa" />
          </baseAddresses>
        </host>
      </service>
      <service behaviorConfiguration="serviceBehavior" name="BrightsideGroup.Repa.Configuration.ConfigurationWCFAdminService">
        <endpoint address="ConfigurationAdminService" binding="netTcpBinding"
          bindingConfiguration="tcpBinding" name="tcpConfigurationAdmin"
          contract="BrightsideGroup.Repa.Configuration.IConfigurationAdminWCFService" />
        <endpoint binding="mexHttpBinding" address="mex" name="mex" contract="IMetaDataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://GD01316:9124/Repa" />
            <add baseAddress="http://GD01316:8124/Repa" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

【问题讨论】:

    标签: .net wcf exception-handling metadata wcf-configuration


    【解决方案1】:

    您的大小写不正确 - WCF 配置区分大小写

     <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
    

    注意IMetadataExchange 中的“D”不是大写的。您可以仔细检查syntax on MSDN

    【讨论】:

    • 谢谢。我知道它必须是简单的!只见树木不见森林!!谢谢。
    【解决方案2】:

    我正在为所有人使用 NetTcpBinding。就我而言,我遇到了同样的问题并通过添加解决了它:

    (a) 到 mex 端点的 behaviorConfiguration=""

    <endpoint address="mex" 
              binding="mexTcpBinding" 
              contract="IMetadataExchange" 
              behaviourConfiguration="" />
    

    (b) 服务定义的 behaviorConfiguration="mex":

    <services>
        <service name="AcmeService" behaviourConfiguration="mex">
    

    (c) 行为入口

    <behaviors>
        <serviceBehaviors>
            <behaviour name="mex">
                <serviceDebug includeExceptionDetailInFaults="false"/>
                <serviceMetadata />
            </behavior>
         </serviceBehaviors>
     </behaviors>
    

    【讨论】:

      【解决方案3】:

      希望following link可以为您提供帮助。

      并尝试添加以下内容:

      <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      

      【讨论】:

      • 标记为已回答问题,这不起作用,因为它是错误的协议,我使用的是 http,而不是 net.tcp。
      • 因为我在基地址中看到了 net.tcp 的条目,我推测您也在使用它。另外,当我回答这个问题时,我没有收到关于存在另一个答案的警报。谢谢。
      猜你喜欢
      • 2012-02-17
      • 1970-01-01
      • 1970-01-01
      • 2014-11-09
      • 2020-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多