[英]How to include Web reference endpoint configuration in another project
I have 2 projects, X and Y. Y calls a Web service and the configuration is defined in Y's app.config (its a DLL).我有 2 个项目,X 和 Y。Y 调用 Web 服务,配置在 Y 的 app.config(它的 DLL)中定义。
When X calls Y methods, I get the following exception:当 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.
How can I include/import Y's app.config into X's web.config so it will have this configuration?如何将 Y 的 app.config 包含/导入到 X 的 web.config 中,以便它具有此配置?
Thank you!谢谢!
You can not include configuration files of one project into another.您不能将一个项目的配置文件包含到另一个项目中。
What you can do is make a new configuration file in X project (that has only the configuration for that web service) and then include that configuration file into your main web.config of X.您可以做的是在 X 项目中创建一个新的配置文件(仅包含该 web 服务的配置),然后将该配置文件包含到 X 的主 web.config 中。
eg.例如。
Lets say you make a new configuration file with name "Endponts.config"假设您创建了一个名为“Endponts.config”的新配置文件
it looks like看起来像
<endpoints>
......
</endpoints>
and then you can use this Endpoints.config file in your main web.config file in the following manner然后您可以通过以下方式在主 web.config 文件中使用此 Endpoints.config 文件
<system.web>
...
<endpoints configSource="Endponts.config" />
...
</system.web>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.