简体   繁体   中英

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

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.

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

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.

eg.

Lets say you make a new configuration file with name "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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM