Benjamin Ortuzar
Benjamin Ortuzar

Reputation: 7831

Reading web-service information from assembly app.config file

I have a plugin architecture solution written in .NET C# 3.5, where each plug-in is an assembly loaded by the main project.

Each plug-in can optionally consume web-service, so I would like to have the configuration of that plugin in its own plugin.dll.config file instead of having it in the app.config of the main project.

I have been looking around and I saw that i could load from each class its own config file:

// Get the application configuration file.
    System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap,userLevel)

I see how that would help me get the basic settings from the appSettings section, but I cant see a way to read the web-service information stored in the plugin.dll.config file.

Any help on how to approach this situation is very welcome.

Upvotes: 3

Views: 1426

Answers (2)

Matt DeKrey
Matt DeKrey

Reputation: 11932

Once you've loaded in the configuration from another location, you can use a ServiceModelSectionGroup.GetSectionGroup(config) call to retrieve the <system.serviceModel> group. Take a look at the ServiceModelSectionGroup's member documentation and pay special attention to properties like Client - I think it will get you the information you're looking for.

Good luck! Let me know if you need more details; I'll need a bit of sample configuration that you're wanting to use, etc.

Upvotes: 1

Dirk Brockhaus
Dirk Brockhaus

Reputation: 5062

Here is a solution that overrides the ChanelFactory to use external configuration files.

Upvotes: 3

Related Questions