gpt4 book ai didi

c# - 如何在另一个项目中包含 Web 引用端点配置

转载 作者:太空宇宙 更新时间:2023-11-03 14:17:55 25 4
gpt4 key购买 nike

我有 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>

关于c# - 如何在另一个项目中包含 Web 引用端点配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6174273/

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