How can I get assembly.dll.config file?
H开发者_运维问答ow can I get ahold of assembly.dll.config in the bin of an executing application in .net?
Attach a config file for a .NET library (dll) is not a good approach. What if this dll is installed into GAC? Where is the config file supposed to be loaded? All settings are recommended to be stored in app.config for the executable.
ConfigurationManager Class ???
String strPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
I have used the following code in the past to get the config file as an XmlDocument (Please note that this assumes the '.config' extension on the config file):
System.Reflection.Assembly asm = System.Reflection.Assembly.GetCallingAssembly();
string cfgFile = asm.CodeBase + ".config";
System.Xml.XmlDocument doc = new XmlDocument();
doc.Load(new XmlTextReader(cfgFile));
精彩评论