2016-12-28 85 views
-1

我创建了WCF服务并且Web.Config文件具有以下设置。在ServiceModel客户端配置部分中找不到引用合同的默认端点元素

<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项目,我已经创建Servcie参考的名称CatpricingService和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

感谢

+0

你提到了app.config,这个app.config是在你的ClassLibrary项目中还是在另一个引用你的ClassLibrary的项目中? –

+0

此app.config文件仅在ClassLirary项目中。 – Ritha

+0

好的,请看下面的答案。 –

回答

3

您需要配置从app.config移动在ClassLibrary项目主体工程的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); 
+0

我有Excel.exe作为外部启动程序。我在我的问题中更新了这一点。 – Ritha

+0

@Ritha,所以你的意思是Excel.exe会消耗你的DLL? –

+0

是的金。我通过复制配置文件解决了这个问题。 – Ritha

0

通过复制应用程序最终解决它。配置文件通过重命名为Excel.exe.config到此文件夹C:\ Program Files \ Microsoft Office \ Office14 \。由于从那里应用程序正在运行,它正在那个位置寻找配置文件。

相关问题