Configuration appsettings

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

Guest

Hi. I have a windows VB .NET application and the app.config file has an entry like this
<add key="key0" value="(###) ###-####" /
In my form load event handler, there is a line like
strDefaultPhoneFormat = ConfigurationSettings.AppSettings("key5"
But the debugger tells me strDefaultPhoneFormat contains Nothing after retrieving that settings value
If I copy the config file to the exe directory and run the program, the config file gets deleted every time the application starts, why? How can I prevent this

Any help with this will be appreciated
Thank
 
to retrieve a config key's value use
dim sKey as String = ConfigurationSettings.AppSettings("[keyname]").ToString(

when you build an executable, the app.config file will be created in the \bin folder and named as [YourAssemblyName].exe.config and the assembly will use this file

app.config should still be in the root folder of your project/solution
 
Back
Top