devlife
devlife

Reputation: 16145

How can I get assembly.dll.config file?

How can I get ahold of assembly.dll.config in the bin of an executing application in .net?

Upvotes: 1

Views: 898

Answers (3)

Jonathan Williams
Jonathan Williams

Reputation: 2055

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));

Upvotes: 0

Lex Li
Lex Li

Reputation: 63163

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.

Upvotes: 2

abmv
abmv

Reputation: 7098

ConfigurationManager Class ???

String strPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().CodeBase);

Upvotes: 1

Related Questions