如何纳入其他项目Web引用端点配置 [英] How to include Web reference endpoint configuration in another project

查看:177
本文介绍了如何纳入其他项目Web引用端点配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个项目,X和YŸ调用Web服务和配置Y轴的app.config中(它的一个DLL)中定义的。

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).

所谓X Ÿ调用方法,我得到了以下异常:

When X calls Y methods, I get the following exception:

 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文件,因此将有此配置?

How can I include/import Y's app.config into X's web.config so it will have this configuration?

感谢您!

推荐答案

您不能包括配置文件一个项目到另一个。

You can not include configuration files of one project into another.

你可以做的是使X项目新的配置文件(即只针对Web服务配置),然后包括配置文件到你的X的主要web.config中。

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.

如:

比方说你犯了一个新的配置文件名称为Endponts.config

Lets say you make a new configuration file with name "Endponts.config"

它看起来像

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



,然后你可以通过以下方式使用此Endpoints.config文件在主web.config文件

and then you can use this Endpoints.config file in your main web.config file in the following manner

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

这篇关于如何纳入其他项目Web引用端点配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆