cannot get any app settings after renaming app.config

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there, it is driving me crazy. Aftering renaming app.config the following
code I always get null on myApp. It works if I keep the name app.config. Why?

string myApp = ConfigurationSettings.AppSettings["AppName"];

Thanks!
 
Hi,

The IDE recognizes 'app.config' as a special name for the application
configuration file. When you build your project, this file is renamed to
'<yourappname>.exe.config' and copied to the output folder. If you rename
the source file to anything other than 'app.config', the IDE will no more
treat it in any automatic fashion.
 
Hi Dmytro,

Thanks for your reply. I am just wondering why it allows me to rename but it
doesn't work if so? I did see some posts here saying they made it work after
renaming, I tried as what they suggested but still not working. Did I missing
anything?

Thanks

Cloud

Dmytro Lapshyn said:
Hi,

The IDE recognizes 'app.config' as a special name for the application
configuration file. When you build your project, this file is renamed to
'<yourappname>.exe.config' and copied to the output folder. If you rename
the source file to anything other than 'app.config', the IDE will no more
treat it in any automatic fashion.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


cloudx said:
Hi there, it is driving me crazy. Aftering renaming app.config the
following
code I always get null on myApp. It works if I keep the name app.config.
Why?

string myApp = ConfigurationSettings.AppSettings["AppName"];

Thanks!
 
Back
Top