System.Configuration.AppSettingsReader with Reflection
-
Here is the thing: I reflect a class library assembly and instance a object without problems, but when I use a System.Configuration.AppSettingsReader object (to get the reflected module config), the readed config is the one of the Main app and not the one of the class library assembly. Any idea on how to solve this? I'm using .Net 2.0 Thanks I'm on a Fuzzy State: Between 0 an 1
-
Here is the thing: I reflect a class library assembly and instance a object without problems, but when I use a System.Configuration.AppSettingsReader object (to get the reflected module config), the readed config is the one of the Main app and not the one of the class library assembly. Any idea on how to solve this? I'm using .Net 2.0 Thanks I'm on a Fuzzy State: Between 0 an 1
I solved myself: private void CreateSchedule() { System.Reflection.Assembly ASM = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.FileInfo FileInfo = new System.IO.FileInfo(ASM.Location + ".config"); System.Xml.XmlDocument XmlDocument = new System.Xml.XmlDocument(); XmlDocument.Load(FileInfo.FullName); string Value; foreach (System.Xml.XmlNode Node in XmlDocument.SelectNodes("configuration/appSettings/add")) { Value = Node.Attributes.GetNamedItem("value").Value; switch (Node.Attributes.GetNamedItem("key").Value) { case "XXXXXXX": // My code here break; case "YYYYYYY": // My code here break; default: break; } } } I'm on a Fuzzy State: Between 0 an 1