我知道这已经被问过很多次,并且回答过很多次,但是,所有提供的应该工作的样本今天似乎都不想为我工作。
当我尝试启动主机时,我不断收到以下错误:
“在服务 TraceService 实施的合同列表中找不到合同名称‘IMetadataExchange’。将 ServiceMetadataBehavior 添加到配置文件或直接添加到 ServiceHost 以启用对此合同的支持。”
根据 Microsoft 的示例,我的服务托管在托管 Windows 服务主机中:http: //msdn.microsoft.com/en-us/library/ms733069%28v=vs.90%29.aspx
这是我漂亮而简单的配置:
<system.serviceModel>
<services>
<service name="Daff.Lae.Service.TraceService">
<endpoint address="" binding="wsHttpBinding" name="TraceService" contract="Contracts.Service.ITraceService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/TraceService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
当然,如果我删除这一行,当没有错误时问题会变得更有趣:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
任何帮助将非常非常非常感激:)