Plugin to use its own app.config

前端 未结 6 1281
星月不相逢
星月不相逢 2021-02-19 21:22

I finally managed to build a working solution of a plugin architecture with help of some guys over here, but now a new problem arises.

My hosting application uses it\'s

6条回答
  •  有刺的猬
    2021-02-19 21:53

    I'm a colleague of Erik. Since he'll be on a well deserved holiday the next few weeks I'll elaborate a bit more on this issue.

    In our plugins, we use multiple instances of WCF service clients. The neat thing of these services is that they come with app.config sections which you can use to configure the behavior, servicetype, security, etc. etc.

    Now when we load our plugins, these sections are missing from config and therefore the correct endpoints can't be found. Of course we could set them in code, but that kind of whacks the ability to set other config options along the way when needed. We might want to implement ws-security for instance.

    So we need a way to load these configs so the plugins can read there respective settings. We could of course merge all configs into one, but that kind of eliminates the "just plugin" method since you would have to manage configs alongside the plugin installation.

    I thought about creating a little tool which would merge the 'master' config with all configs placed in a subdir of the project and replace the .exe.config file with that one. I think that would work, but I was wondering if .NET doesn't provide better options. Multiple AppDomains isn't a thing which would work because the plugins have to interact (provider/consumer model) with each other and we don't want to switch to remoting just because of this issue.

    Update: I fixed most issues by using the ConfigurationManager to open existing configs for reading appSettings. As for the WCF clients; you can load endpoint/binding configuration for server and client as found here: http://weblogs.asp.net/cibrax/archive/2007/10/19/loading-the-wcf-configuration-from-different-files-on-the-client-side.aspx

提交回复
热议问题