2011-05-30 66 views
2

我有2個項目,X和Y. Y調用Web服務,配置在Y的app.config(它的一個DLL)中定義。如何在其他項目中包含Web參考端點配置

當XŸ調用方法,我得到以下異常:

System.InvalidOperationException: Could not find default endpoint element that references contract 'xxxx.ServiceSoap' 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. 

我怎麼能包括/導入個Y的app.config到X的web.config所以它都會有這樣的配置呢?

謝謝!

回答

1

您不能將一個項目的配置文件包含到另一個項目中。

你可以做的是使X項目中的新的配置文件(即只有配置爲Web服務),然後包括配置文件到您的X.

例如主要的web.config。

比方說你犯了一個新的配置文件名稱爲「Endponts.config」

它看起來像

<endpoints> 
...... 
</endpoints> 

然後你就可以在你的主web.config文件中使用此Endpoints.config文件

<system.web> 
    ... 
    <endpoints configSource="Endponts.config" /> 
    ... 
    </system.web> 
+0

你確定它應該住在? – Himberjack 2011-05-30 10:24:22

+0

它取決於您要導入的設置,標準Web設置進入,現在您的案例是端點(您充當客戶端),那麼它將進入/。 – Sumit 2011-05-30 10:51:39

相關問題