Need web service URL to be configurable
Posted on 2011-09-20
We have a Visual Studio 2010 solution with multiple projects. The startup project is a winforms project and has a reference to a class library project in the same solution. The class library project has a web reference to a classic ASP.Net web service not in the solution. So the dependency chart is like:
Winform startup project -> Class Library Project -> ASP.Net web service
Due to some constraints, we have to keep the web reference on the class library project.
The code works perfectly fine. The startup project calls a class's method in the class library and the class method calls the web service.
The question is - how do I make the URL of the web service configurable? The app.config file on the class library has the URL to the web service. But the solution does not use that app.config at runtime.
I changed the reference.cs (under web reference on the class library) file's constructor to read the value from config file.
this.url = read from config file.
But I think Reference.cs will be overwritten the next time the web reference is updated.
I am sure there is a better solution to this problem? Please help.
All code is written in C# and we are using .Net 4.0.