gpt4 book ai didi

c# - 在 ServiceModel 客户端配置部分找不到引用契约(Contract)的默认端点元素......................

转载 作者:行者123 更新时间:2023-12-05 08:33:23 27 4
gpt4 key购买 nike

我已经创建了一个 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

谢谢

最佳答案

您需要将配置从ClassLibrary 项目中的app.config 移动到主项目的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);

关于c# - 在 ServiceModel 客户端配置部分找不到引用契约(Contract)的默认端点元素......................,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41364836/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com