Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Configuration file for application

Configuration file for application

Scheduled Pinned Locked Moved C#
tutorialquestionlearningworkspace
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tomiga
    wrote on last edited by
    #1

    Welcome, I hava a project called for example myApp I defined configuration file myApp.config as below Construction myApp looks like ... System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); try { strConn = ((string)(configurationAppSettings.GetValue("SqlConnection1.ConnectionString", typeof(string)))); } catch(Exception e) { MessageBox.Show(e.Message); } ... And exception occured A key SqlConnection1.ConnectionString in the appSettings configuration section. Do you have any idea what is wrong (I added config file manualy... is it neccasary to set extra references to it) (of course it is added to project) Tomiga

    T J 2 Replies Last reply
    0
    • T tomiga

      Welcome, I hava a project called for example myApp I defined configuration file myApp.config as below Construction myApp looks like ... System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); try { strConn = ((string)(configurationAppSettings.GetValue("SqlConnection1.ConnectionString", typeof(string)))); } catch(Exception e) { MessageBox.Show(e.Message); } ... And exception occured A key SqlConnection1.ConnectionString in the appSettings configuration section. Do you have any idea what is wrong (I added config file manualy... is it neccasary to set extra references to it) (of course it is added to project) Tomiga

      T Offline
      T Offline
      tomiga
      wrote on last edited by
      #2

      oppss of course it was xml file.. (it doesn't look like in previous post) Tomiga

      1 Reply Last reply
      0
      • T tomiga

        Welcome, I hava a project called for example myApp I defined configuration file myApp.config as below Construction myApp looks like ... System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); try { strConn = ((string)(configurationAppSettings.GetValue("SqlConnection1.ConnectionString", typeof(string)))); } catch(Exception e) { MessageBox.Show(e.Message); } ... And exception occured A key SqlConnection1.ConnectionString in the appSettings configuration section. Do you have any idea what is wrong (I added config file manualy... is it neccasary to set extra references to it) (of course it is added to project) Tomiga

        J Offline
        J Offline
        James T Johnson
        wrote on last edited by
        #3

        You shouldn't need to create an AppSettingsReader for the configuration file. There is an AppSettings property in the ConfigurationSettings class which is a NameValueCollection, this collection contains all of the keys in the appSettings node of the XML file. Try that and see if it helps. James "Java is free - and worth every penny." - Christian Graus

        T 1 Reply Last reply
        0
        • J James T Johnson

          You shouldn't need to create an AppSettingsReader for the configuration file. There is an AppSettings property in the ConfigurationSettings class which is a NameValueCollection, this collection contains all of the keys in the appSettings node of the XML file. Try that and see if it helps. James "Java is free - and worth every penny." - Christian Graus

          T Offline
          T Offline
          tomiga
          wrote on last edited by
          #4

          Thx Problem was solved. (I had to change a name of config file). Tomiga

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups