G
Guest
From the documentation I could find, it seems that reading “appSettings†from
the app.config file is now done through ConfigurationManager.AppSettings for
..NET 2.0, instead of the obsolete ConfigurationSetting.AppSettings. But
what’s kind of confusing is that “appSetttings†itself seems to be in
disfavor. Accessing “applicationSettings†using My.Settings seems to be the
preferred way.
1st question: Is My.Settings preferred to using ConfigurationManager?
But using My.Settings presents me with this problem. With “appSettingsâ€,
the code would always pull values from MyApp.exe.config. It did not matter
if the code were in the Exe or some DLL that it used. But now if I use
My.Settings.MySetting (or My.Settings.Item(“MySettingâ€) in a non-typed way),
the code will attempt to pull it from the config of the assembly that it is
in. That is, if the code is in the Exe then it will look in
MyApp.exe.config, but if it in the DLL then it will look in MyLib.dll.config.
2nd question: Is there a “My.Settings†way of accessing the config values of
the Executable from code that is in a referenced assembly?
I tried putting “MySetting†in both the app.config files for the Exe and
DLL. I hoped that the Exe value would override the DLL value, but it did not
work. The accessing code in the DLL only found values in MyLib.dll.config.
I guess I could resort to doing the semi-new way of using
ConfigurationManager to read “appSettings†but I am hoping that there is a
general approach to using the Exe’s My.Settings that I haven’t found.
the app.config file is now done through ConfigurationManager.AppSettings for
..NET 2.0, instead of the obsolete ConfigurationSetting.AppSettings. But
what’s kind of confusing is that “appSetttings†itself seems to be in
disfavor. Accessing “applicationSettings†using My.Settings seems to be the
preferred way.
1st question: Is My.Settings preferred to using ConfigurationManager?
But using My.Settings presents me with this problem. With “appSettingsâ€,
the code would always pull values from MyApp.exe.config. It did not matter
if the code were in the Exe or some DLL that it used. But now if I use
My.Settings.MySetting (or My.Settings.Item(“MySettingâ€) in a non-typed way),
the code will attempt to pull it from the config of the assembly that it is
in. That is, if the code is in the Exe then it will look in
MyApp.exe.config, but if it in the DLL then it will look in MyLib.dll.config.
2nd question: Is there a “My.Settings†way of accessing the config values of
the Executable from code that is in a referenced assembly?
I tried putting “MySetting†in both the app.config files for the Exe and
DLL. I hoped that the Exe value would override the DLL value, but it did not
work. The accessing code in the DLL only found values in MyLib.dll.config.
I guess I could resort to doing the semi-new way of using
ConfigurationManager to read “appSettings†but I am hoping that there is a
general approach to using the Exe’s My.Settings that I haven’t found.