簡體   English   中英

如何在另一個項目中包含 Web 參考端點配置

[英]How to include Web reference endpoint configuration in another project

我有 2 個項目,X 和 Y。Y 調用 Web 服務,配置在 Y 的 app.config(它的 DLL)中定義。

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

 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 中,以便它具有此配置?

謝謝!

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

您可以做的是在 X 項目中創建一個新的配置文件(僅包含該 web 服務的配置),然后將該配置文件包含到 X 的主 web.config 中。

例如。

假設您創建了一個名為“Endponts.config”的新配置文件

看起來像

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

然后您可以通過以下方式在主 web.config 文件中使用此 Endpoints.config 文件

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM