.net - 在服务实现的合约列表中找不到 IMetaDataExchange

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

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

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

我有一个 Windows 服务,托管两个契约(Contract):

  • IConfigurationService
  • IConfigurationAdminService

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

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

    然后我得到以下异常:

    The contract name 'IMetaDataExchange' could not be found in the list of contracts implemented by the service 'ConfigurationWCFService'.



    这是我的配置,一切都由配置配置,没有通过代码完成。
    <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>
    

    最佳答案

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

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

    请注意,IMetadataExchange 中的“D”没有大写您可以仔细检查 syntax on MSDN .

    关于.net - 在服务实现的合约列表中找不到 IMetaDataExchange,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3871827/

    相关文章:

    java - Spring MVC 中的模型填充 @ExceptionHandler

    ruby-on-rails - Rails 异常通知插件 - 强制发送电子邮件

    .net - 无法使用 StackExchange.Redis 连接到 C# 中的 Azure Redis 缓存(超时错误)

    .net - 为什么 .NET 会突然尝试序列化 ASP.NET 应用程序中的对象?

    .net - 模拟 WCF 客户端代理的最佳方法

    .net - 在使用 MVVM 设计模式的 WPF 应用程序中使用 WCF 服务作为模型

    c++ - try-catch block 是否会降低性能

    用于确定计算机是否使用电池供电的 C# 技术?

    .net - 如何追踪 log4net 问题

    .net - HTTP 方法 GET、POST、PUT 和 DELETE 之间有什么区别