I've got a Windows Service that makes use of a plugin system. I'm using the following code in the plugin base class to provide a separate configuration per DLL (so it'll read from plugin.dll.config
):
string dllPath = Assembly.GetCallingAssembly().Location;
return ConfigurationManager.OpenExeConfiguration(dllPath);
These plugins need to make calls to WCF services, so the problem I'm running into is that new ChannelFactory<>("endPointName")
only looks in the hosted application's App.config for the endpoint configuration.
Is there a way to simply tell the ChannelFactory to look in another configuration file or somehow inject my Configuration
object?
The only way I can think of to approach this is to manually create an EndPoint and Binding object from values read in from plugin.dll.config
and pass them to one of the ChannelFactory<>
overloads. This really seems like recreating the wheel though, and it could get really messy with an endPoint that makes heavy use of behavior and binding configurations. Perhaps there's a way to create EndPoint and Binding objects easily by passing it a configuration section?
null
and it'll use the configured address. Thanks for posting! – Gregorio