开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜