المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to change Web Service url dynamically when it's referenced in a class library (dll) ?



C# Programming
06-30-2009, 02:00 PM
Hi Guys,

My .net 3.5 solution contains a wpf application and a class library project (dll).
The dll is referenced (add reference --> projects tab) by the wpf app.
I added a web reference to the class library and configured its "URL Behavior" to dynamic,
so that when I deploy the application I could replace the WS's url in the app setting.

An app.config file was automatically generated in the class library project, containing the settings for the project:















http://localhost/MyServices/DataService.asmx






When I build the solution, only the wpf.exe.config file is created - the dll.config
file is not copied to the output directory.
I thought maybe the settings were merged but the wpf.exe.config file doesn't contain
the above settings from the class library app.config.

Bottom line - If the dll config file is not copied / merged to the exe config, I can't change the url of the WS!
The code in the class library will always use the default values since it won't find it in and application setting.

I know I can manually copy the dll's settings section from its app.config file
to the WPF's app.config file, but this sounds like a bad idea.

What is the right way to complete my goal?

Thanks,
Shaul