首页 文章

WCF IMetadataExchange错误

提问于
浏览
0

我创建了一个具有以下配置的服务主机 .

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="MathServiceLib.MathService" behaviorConfiguration="myMathServiceBehave">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:9001/MathService"/>
            <add baseAddress="net.tcp://localhost:9002/MathService"/>
          </baseAddresses>
        </host>
        <endpoint address="http://localhost:9001/MathService" binding="basicHttpBinding" contract="MathServiceLib.IMathService"/>
        <endpoint address ="net.tcp://localhost:9002/MathService" binding ="netTcpBinding" contract="MathServiceLib.IMathService"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <!--<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>-->
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="myMathServiceBehave">
          <!--<serviceMetadata httpGetEnabled="true"/>-->
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

我不想使用serviceMetadata httpGetEnabled =“true”属性,而是想使用MEX绑定来创建代理 .

现在我开始使用我的服务

svcHost = new ServiceHost(typeof(MathServiceLib.MathService));
 svcHost.Open();

我得到以下错误,请帮助 .

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

1 回答

相关问题