views:

1009

answers:

4

I am facing a problem.

I have a dll which is interacting with a webservice and it saves its endpoint configuration in its app.config file.

I want to use this dll from my host application. The host application has its own config file. I have to merge the contents of dll's config to host's config each time when I change service endpoint.

Is there a way that I can use both config files. So the dll uses its own config whereas host application use its own config.

A: 

The right way is to merge the DLL's config file into the EXE's; that'll work out of the box. But see http://stackoverflow.com/questions/1599539/net-dll-settings-and-config-when-theres-a-web-reference-whats-going-on for a way to explicitly open a config file and read it. The problem is that you'd need to FIND the config file first, and that's not necessarily easy. If the DLL is just sitting around, you could check the same directory. But if it's in the GAC, where do you look? I suggest sticking to the right way.

Steven Sudit
+2  A: 

config files can include external files.

If you'd put the endpoint's config onto an external file, and then include it in yout host, you won't need to change the host's config every time

see link text

Ken Egozi
A: 

This may help if you are using svcutil to generate your proxy: check the /config: and /mergeConfig switches, with those you can specify which config file receives the generated info and you can merge it in instead of just overwriting whatever is already there.

slugster
A: 

Here is an article which might be helpful -

Kapilg