EDN Admin
Well-known member
Unable to read a dlls congig file say "Test.dll.config" where Test is the name of my dll using following piece of code. "ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().CodeBase).AppSettings.Settings["Condition"].Value"
We have various dlls that will be read by multiple applications and these dlls have config file of their own. Now coming to the problem, we are referencing a dll from these various dlls in a Windows Forms application. With above piece of code able to read
various settings from dlls config file.
But we have another common dll that is referenced by all the dlls that we have and, this has its own config file. So these settings are common for all our dlls stated above. Now in this dll if I use the same piece of code as stated above I am not able to
read settings. Somehow, some default config file is read instead of my config file. The path that is being referenced is correct and the proper config file is present at the respective path. Not sure why the AppSettings.Settings["Condition"]
is throwing exception. Same exception is also observed if I try to read the Section information using "GetSectionGroup". And the exception message and inner exception are not informative as following message is displayed at both places.
"Object reference not set to an instance of an object."
I know that it is not good to have configurations/settings in multiple config files and it is always the best for an user to have everything in the applications config file. But my requirement is as stated above and cannot be changed.<br/>
Any help on this is heart-fully appreciated as I am struggling with this from two weeks.
View the full article
We have various dlls that will be read by multiple applications and these dlls have config file of their own. Now coming to the problem, we are referencing a dll from these various dlls in a Windows Forms application. With above piece of code able to read
various settings from dlls config file.
But we have another common dll that is referenced by all the dlls that we have and, this has its own config file. So these settings are common for all our dlls stated above. Now in this dll if I use the same piece of code as stated above I am not able to
read settings. Somehow, some default config file is read instead of my config file. The path that is being referenced is correct and the proper config file is present at the respective path. Not sure why the AppSettings.Settings["Condition"]
is throwing exception. Same exception is also observed if I try to read the Section information using "GetSectionGroup". And the exception message and inner exception are not informative as following message is displayed at both places.
"Object reference not set to an instance of an object."
I know that it is not good to have configurations/settings in multiple config files and it is always the best for an user to have everything in the applications config file. But my requirement is as stated above and cannot be changed.<br/>
Any help on this is heart-fully appreciated as I am struggling with this from two weeks.
View the full article