How can I get ahold of assembly.dll.config in the bin of an executing application in .net?
+1
A:
ConfigurationManager Class ???
String strPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
abmv
2009-11-17 06:55:00
+1
A:
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.
Lex Li
2009-11-17 07:31:11
A:
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));
Jonathan Williams
2010-03-25 16:41:22