tags:

views:

51

answers:

1

Good afternoon,

I am writing a DLL that that leverages WCF to make a web services call. Normally this is fairly straightforward: I configure the endpoint in the .config file and be done with it. However, in this case, the DLL can be called in one of several contexts and depending on the context, the endpoint might change. The behavior of the DLL remains unchanged.

I would like to use one copy of the DLL, but I'm having trouble figuring out how to make this work. I could set up multiple instances of the endpoint and do a case statement, but I'm looking for something a little more extensible. I've thought of a couple of things.

  • Changing the endpoint on the fly; I have the ability to pass config data into the DLL and could pass the endpoint in. However, this only allows me to change the endpoint not the protocol or anything else.
  • Keeping multiple config files and passing the path to the appropriate config file. This seems really messy and I'm not sure how it would work.

I'm hoping to get some other ideas of how I might handle this situation. I can't seem to come up with something elegant.

Thanks!

+2  A: 

Why couldn't you have different *.dll.config files for each different context?

In the config file you can specify endpoints, and read the endpoint in in the DLL.

This is what Application Settings were designed for.

John Weldon
I think that would work, but how do I indicate which config file to read?
Jacob
Thanks for pointing me to that. Very helpful!
Jacob
You're welcome :)
John Weldon