Reading web service information from the app.config file collector

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

Each plugin can optionally use a web service, so I would like to have the configuration of this plugin in my own plugin.dll.config file instead of having it in the app.config of the main project.

I look around and I saw that I can load my own configuration file from each class:

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

I see how this will help me get the basic settings from the appSettings section, but I see no 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.

+3
source share
2 answers

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

+3
source

Once you have downloaded the configuration from another location, you can use the call ServiceModelSectionGroup.GetSectionGroup(config)to retrieve the group <system.serviceModel>. Take a look at the documentation ServiceModelSectionGroupand pay special attention to properties such as Client - I think he will provide you with the information he is looking for.

Good luck Let me know if you need details; I need a little sample configuration that you want to use, etc.

+1
source

Source: https://habr.com/ru/post/1741907/


All Articles