Is there any way to access the "System.ServiceModel" client configuaration i.e. app.config in a class based (dll) project?
ConfigurationManager.GetSection(string)
lets you open a section from the executing application's app.config or web.config. but system.ServiceModel
isn't a section, it's a section group. ConfigurationManager
doesn't provide a way to get a section group.
There are ways to get to a Configuration
without ConfigurationManager
, but it's a little messy because you have to distinguish between an app.config and web.config.
But if you can skip past system.ServiceModel
to the actual configuration group that you want then it's really easy because you can use ConfigurationManager
. For example,
var section = ConfigurationManager.GetSection("system.serviceModel/client");
Or you can make it strongly typed:
var section = (ClientSection)ConfigurationManager.GetSection("system.serviceModel/client");
or
var behaviorSection =
(BehaviorsSection)ConfigurationManager.GetSection("system.serviceModel/behaviors");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With