How does .NET applications probing for their configuration files?
I know there's some kind开发者_运维技巧 of assembly probing process. Is there a similar process for looking for config files? If there is, what exact process is it? How could I customize it?
Many thanks.
Class libraries does not have their own config files but rather use the one of the application so you can't get exactly what you want. However, there might be ways to mimic this in certain ways depending on exactly what you need.
Here's a blog post that discusses a possible solution to this:
http://moebiusit.com/blog/2010/07/13/changing-dll-settings-without-re-compiling/
It seems that you wish to initiate or load different class/object (in different DLLs) with a different set of configuration. So the pattern that supports such needs is the Dependency Injector. You can look into some DI framework for this. The standard config loading does not provide such functionality.
精彩评论