Results 1 to 6 of 6

Thread: VB2005 App.config

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    VB2005 App.config

    Hello,

    Does anyone have a code example on how to read/write to the app.config file within an application? Here is a sample from my file:
    <configuration>
    <appSettings>
    <add key="Authentication" value="Windows"/>

    How would I read that value? It's NOT the same way you would do it in 2003. I tried but when I tried using

    configuration.configurationsettings.getconfig("Authentication"), I get the message that "This method is obsolete, use system.configuration.configurationmanager.getsection instead."

    But that method does not work either. Any ideas?

  2. #2
    Addicted Member bgard68's Avatar
    Join Date
    Mar 2006
    Location
    Arkansas
    Posts
    164
    Using Framework 1.1, VB.Net 2003 unless I
    state otherwise

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Re: VB2005 App.config

    Getting a message "Configuration Manager is not a member of Configuration". So this is still not working. I referenced the system.configuration DLL file to the project and still nothing. Any other suggestions?
    Last edited by rjdpa; Mar 20th, 2006 at 12:43 PM.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB2005 App.config

    You should probably be using application settings instead. Go to the Settings tab of the application properties and create a new setting named "Authentication". Make it type String and set the value to "Windows". Now at run time you just get it via My.Settings.Authentication. That's it. You can still use the old way if you like but it is much more tedious. Using settings allows you to easily change the value at run time as well if you want to.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    133

    Re: VB2005 App.config

    I'm not able to figure out how to write the values into the settings. I will keep trying on the app.config... If anyone has any suggestions, please let me know.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB2005 App.config

    I've done a bit more reading on application settings and it appears that if you set the scope of a setting to Application then it becomes ReadOnly as far as My.Settings is concerned. If you set the scope as User then you can change the values and save them using My.Settings.Save() but it will save the settings for the current user and not for all users.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width