繁体   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