簡體   English   中英

在ServiceModel客戶端配置部分中找不到引用合同的默認端點元素。

[英]Could not find default endpoint element that references contract… in the ServiceModel client configuration section

我已經創建了WCF服務,並且Web.Config文件具有以下設置。

 <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" sendTimeout="10:00:00" openTimeout="10:00:00">
      <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="Axis.OptimizationService.RMSCalculationService">
    <endpoint address="" binding="basicHttpBinding" contract="Axis.RMS.Optimization.Contracts.IRMSCalculationService"></endpoint>
  </service>
</services>
<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"  minFreeMemoryPercentageToActivateService="0"/>

在我的ClassLibrary項目中,我創建了名稱為CatpricingService的Servcie參考,並且app.config文件如下所示。

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IRMSCalculationService" closeTimeout="00:30:00"
        openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="01:00:00"
        maxBufferPoolSize="0" maxReceivedMessageSize="2147483647"
        useDefaultWebProxy="true" />
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost:2200/RMSCalculationService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRMSCalculationService"
    contract="CatPricingService.IRMSCalculationService"  name="BasicHttpBinding_IRMSCalculationService" />
</client>

我不確定我在做什么錯。 我做了幾次。 我不知道是什么錯誤。 對我來說,所有設置似乎都是正確的。 我收到此錯誤。

Could not find default endpoint element that references contract 'CatPricingService.IRMSCalculationService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

我在Stackoverflow上提到了其他問題。 誰能弄清楚我的設置出了什么問題?

在這里,我的ClassLibrary項目正在使用外部程序excel.exe運行。 (項目屬性,“調試”選項卡,選擇“啟動外部程序”,並賦值為C:\\ Program Files \\ Microsoft Office \\ Office14 \\ EXCEL.EXE

謝謝

你需要移動從配置app.configClassLibrary項目的app.config的主要項目(例如,一個WPF應用程序)的。 可能是引用您的ClassLibrary的項目。

執行程序時,將僅使用主項目中的app.config

更新:

在這種情況下,我認為您需要以編程方式創建客戶端類,而不依賴於app.config ,如下所示:

var binding = new BasicHttpBinding();
var endPointAddress = new EndpointAddress("http://localhost:2200/RMSCalculationService.svc");
var client = new YourGeneratedClientClass(binding, endPointAddress);

最后通過將app.config文件重命名為Excel.exe.config復制到此文件夾C:\\ Program Files \\ Microsoft Office \\ Office14 \\來解決該問題。 由於應用程序從那里開始運行,因此它將在該位置查找配置文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM