简体   繁体   English

在ServiceModel客户端配置部分中找不到引用合同的默认端点元素。

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

I have created a WCF service and Web.Config file has below settings. 我已经创建了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"/>

In my ClassLibrary project, I have created Servcie reference with the name CatpricingService and the app.config file looks as below. 在我的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>

I am not sure what I am doing wrong here. 我不确定我在做什么错。 I did this several times. 我做了几次。 I could not figure out what the error is. 我不知道是什么错误。 To me all settings seems correct. 对我来说,所有设置似乎都是正确的。 I am getting this error. 我收到此错误。

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.

I referred other questions on Stackoverflow..... im going nuts with this. 我在Stackoverflow上提到了其他问题。 Can anyone figure out what is wrong with my settings? 谁能弄清楚我的设置出了什么问题?

Here my ClassLibrary project is running with external program excel.exe. 在这里,我的ClassLibrary项目正在使用外部程序excel.exe运行。 (Project properties, Debug tab, selected "Start external program" and gave value as C:\\Program Files\\Microsoft Office\\Office14\\EXCEL.EXE (项目属性,“调试”选项卡,选择“启动外部程序”,并赋值为C:\\ Program Files \\ Microsoft Office \\ Office14 \\ EXCEL.EXE

Thanks 谢谢

You need to move the configuration from app.config in your ClassLibrary project to the app.config of the main project (for example, an WPF application). 你需要移动从配置app.configClassLibrary项目的app.config的主要项目(例如,一个WPF应用程序)的。 Probably it is the project which references your ClassLibrary . 可能是引用您的ClassLibrary的项目。

Only app.config in the main project will be used when your program executes. 执行程序时,将仅使用主项目中的app.config

Updated: 更新:

In this case, I think you need to create client class programmatically, do not depend on app.config , something like this: 在这种情况下,我认为您需要以编程方式创建客户端类,而不依赖于app.config ,如下所示:

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

Finally solved it by copying the app.config file by renaming to Excel.exe.config to this folder C:\\Program Files\\Microsoft Office\\Office14\\ . 最后通过将app.config文件重命名为Excel.exe.config复制到此文件夹C:\\ Program Files \\ Microsoft Office \\ Office14 \\来解决该问题。 Since from there the Application is running it is looking for Config file at that location. 由于应用程序从那里开始运行,因此它将在该位置查找配置文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在ServiceModel客户端配置部分中找到引用合同“IAuthenticationService”的默认端点元素 - Could not find default endpoint element that references contract 'IAuthenticationService' in the ServiceModel client configuration section 在ServiceModel客户端配置部分中找不到引用contract的默认终结点元素。 - Could not find default endpoint element that references contract.in the ServiceModel client configuration section 在ServiceModel客户端配置部分中找不到名称为``and contract&#39;&#39;的终结点元素 - Could not find endpoint element with name '' and contract '' in the ServiceModel client configuration section 在 ServiceModel 客户端配置部分中找不到名称为“xxxxx”且合同为“yyy”的端点元素 - Could not find endpoint element with name 'xxxxx' and contract 'yyy' in the ServiceModel client configuration section 找不到引用合同的默认端点元素 - Could not find default endpoint element that references contract 找不到引用合同的默认端点元素? - Could not find default endpoint element that references contract? “找不到引用合同的默认端点元素” - “Could not find default endpoint element that references contract” 找不到引用合同的默认端点元素 - Could not find default endpoint element that references contract 找不到引用合同的默认端点元素 - Could not find default endpoint element that references contract 找不到引用合同的默认端点元素 - Could not find default endpoint element that references contract
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM