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>
精彩评论