WCF 启动主机错误

发布于 2024-12-13 14:34:55 字数 2605 浏览 0 评论 0原文

我想启动以下 WCF 服务:

<system.serviceModel>
  <services>
   <service name="MTPlatform">
      <endpoint address="TradingService" behaviorConfiguration="ServiceBehaviour"
               binding="netNamedPipeBinding"  
               bindingConfiguration="NetNamedPipeBinding_IGenericTradingInterface"
               contract="GenericTradingInterface.IGenericTradingInterface"
               name="TradingService"  />
      <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
           <add baseAddress="net.pipe://localhost" />
        </baseAddresses>
        <timeouts closeTimeout="00:00:02" openTimeout="00:00:20" />
      </host>
   </service>
  </services>
  <bindings>
     <netNamedPipeBinding>
        <binding name="NetNamedPipeBinding_IGenericTradingInterface"
                 closeTimeout="00:05:20" openTimeout="00:00:20" receiveTimeout="05:20:00"
                 sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered"
                 transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard"
                 maxBufferPoolSize="2147483646" maxBufferSize="2147483646" maxConnections="10"
                 maxReceivedMessageSize="2147483646">
              <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
                            maxArrayLength="2147483646" maxBytesPerRead="2147483646" 
                            maxNameTableCharCount="2147483646" />
              <security mode="Transport">
                 <transport protectionLevel="EncryptAndSign" />
              </security>
         </binding>
     </netNamedPipeBinding>
   </bindings>
   <behaviors>
       <endpointBehaviors>
           <behavior name="ServiceBehaviour">
               <dataContractSerializer maxItemsInObjectGraph="2147483646" />
           </behavior>
       </endpointBehaviors>
       <serviceBehaviors>
           <behavior name="MetaDataBehavior">
                <serviceMetadata />
           </behavior>
       </serviceBehaviors>
   </behaviors>
</system.serviceModel>

失败并显示:

在列表中找不到合约名称“IMetadataExchange” MT5Platform 服务执行的合约数量。添加一个 ServiceMetadataBehavior配置文件或 ServiceHost 直接启用对此合约的支持。

我在这里没有看到大错误,哪里可以找到 IMetadataExchange

谢谢,

于尔根

I want to launch the following WCF service:

<system.serviceModel>
  <services>
   <service name="MTPlatform">
      <endpoint address="TradingService" behaviorConfiguration="ServiceBehaviour"
               binding="netNamedPipeBinding"  
               bindingConfiguration="NetNamedPipeBinding_IGenericTradingInterface"
               contract="GenericTradingInterface.IGenericTradingInterface"
               name="TradingService"  />
      <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
           <add baseAddress="net.pipe://localhost" />
        </baseAddresses>
        <timeouts closeTimeout="00:00:02" openTimeout="00:00:20" />
      </host>
   </service>
  </services>
  <bindings>
     <netNamedPipeBinding>
        <binding name="NetNamedPipeBinding_IGenericTradingInterface"
                 closeTimeout="00:05:20" openTimeout="00:00:20" receiveTimeout="05:20:00"
                 sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered"
                 transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard"
                 maxBufferPoolSize="2147483646" maxBufferSize="2147483646" maxConnections="10"
                 maxReceivedMessageSize="2147483646">
              <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
                            maxArrayLength="2147483646" maxBytesPerRead="2147483646" 
                            maxNameTableCharCount="2147483646" />
              <security mode="Transport">
                 <transport protectionLevel="EncryptAndSign" />
              </security>
         </binding>
     </netNamedPipeBinding>
   </bindings>
   <behaviors>
       <endpointBehaviors>
           <behavior name="ServiceBehaviour">
               <dataContractSerializer maxItemsInObjectGraph="2147483646" />
           </behavior>
       </endpointBehaviors>
       <serviceBehaviors>
           <behavior name="MetaDataBehavior">
                <serviceMetadata />
           </behavior>
       </serviceBehaviors>
   </behaviors>
</system.serviceModel>

This fails with:

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

I don't see big mistakes here, where can one find IMetadataExchange?

Thanks,

Juergen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戒ㄋ 2024-12-20 14:34:55

您需要在 元素中引用名为“MetaDataBehavior”的服务行为。另外,为了团队中其他开发人员的理智,请不要使用名为“ServiceBehaviour”的端点行为 - 这是自找麻烦:)

<system.serviceModel>
<services> 
 <service name="MTPlatform" behaviorConfiguration="MetaDataBehavior"> 
  <endpoint address="TradingService" behaviorConfiguration="IncreaseMIIOGEndpointBehaviour" 
   binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IGenericTradingInterface" 
   name="TradingService" contract="GenericTradingInterface.IGenericTradingInterface" /> 
  <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" /> 
  <host> 
   <baseAddresses> 
    <add baseAddress="net.pipe://localhost" /> 
   </baseAddresses> 
   <timeouts closeTimeout="00:00:02" openTimeout="00:00:20" /> 
  </host> 
 </service> 
</services> 
<behaviors> 
 <endpointBehaviors> 
  <behavior name="IncreaseMIIOGEndpointBehaviour"> 
   <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
  </behavior> 
 </endpointBehaviors> 
 <serviceBehaviors> 
  <behavior name="MetaDataBehavior"> 
   <serviceMetadata /> 
  </behavior> 
 </serviceBehaviors> 
</system.serviceModel>

You need to reference the service behavior called "MetaDataBehavior" in your <service> element. Also, for the sake of the sanity of other developers in your team, please don't have an endpoint behavior with a name "ServiceBehaviour" - that's asking for trouble :)

<system.serviceModel>
<services> 
 <service name="MTPlatform" behaviorConfiguration="MetaDataBehavior"> 
  <endpoint address="TradingService" behaviorConfiguration="IncreaseMIIOGEndpointBehaviour" 
   binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IGenericTradingInterface" 
   name="TradingService" contract="GenericTradingInterface.IGenericTradingInterface" /> 
  <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" /> 
  <host> 
   <baseAddresses> 
    <add baseAddress="net.pipe://localhost" /> 
   </baseAddresses> 
   <timeouts closeTimeout="00:00:02" openTimeout="00:00:20" /> 
  </host> 
 </service> 
</services> 
<behaviors> 
 <endpointBehaviors> 
  <behavior name="IncreaseMIIOGEndpointBehaviour"> 
   <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 
  </behavior> 
 </endpointBehaviors> 
 <serviceBehaviors> 
  <behavior name="MetaDataBehavior"> 
   <serviceMetadata /> 
  </behavior> 
 </serviceBehaviors> 
</system.serviceModel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文