How to tell WCF client to read settings out of different config file?

不打扰是莪最后的温柔 提交于 2020-01-03 05:43:10

问题


I'm building a component that is an extension for another software product. It's loaded as a dll into that product, and therefore I don't have control over the main exe's app.config file. My component uses WCF and I'd like to be able to configure it using a .config file instead of programmatically within the code. Is there a way to tell WCF to get all the binding etc settings from a specific config file?


回答1:


The .NET config file mechanism is scoped by AppDomain, so in principle you could achieve this by creating a separate AppDomain to host your WCF stuff. It's quite a lot of work, though, as you would have to code the necessary cross-domain communication to expose your extension functionality to the host process.




回答2:


Ultimately @marc_s's answer was the one I went with: no. Instead we store configuration options with other system settings and then apply them programmatically to the binding etc settings at runtime.



来源:https://stackoverflow.com/questions/4928807/how-to-tell-wcf-client-to-read-settings-out-of-different-config-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!