Dynamic URL Web Service URL is not loaded from applicationSettings section in Console application

I have a class library DLL, that has client web services reference. The reference is dynamic and in generated app.config the URL is listed inside <applicationSettings>.
I am using the class from web Application(WAP) and by copying <..Properties.Settings> to web.config I am able to change the URL just by modifying value in web.config(I even wrote helper class to Update Dynamic Web reference URLs Diring Installation in Visual Studio 2005). The approach is well described in
How to share dynamic URLs across multiple Web Application Projects  post.

I recently tried to call the same client web services class from windows console application. I copied the same section <..Properties.Settings> to console’s app.config, but URL, specified in config file, is ignored, and application uses default hardcoded value.

I tried a few things without success. The troubleshooting is very annoying because  if the corresponding setting in config file not found, .Net infrastructure doesn’t report any warning, but just uses default vaue.  I ended up by writing extra code to read URL from app.settings and explicitely assign URL to web service with the code similar to the following:

service.Url = ConfigurationSettings.AppSettings[“WebServiceUrl”];

It seems that other peoople also sometimes have problems  in setting dynamic URL(for example see Dynamic URL Behavior & Configuration  thread).

Advertisements