2016-12-28 89 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 \。由於從那裏應用程序正在運行,它正在那個位置尋找配置文件。

相關問題