Help using appConfig for application settings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sai

    #1

    Help using appConfig for application settings

    Hi,

    I am using VSTO 2005 Beta for building an excel application. I added
    application configuration file to the project (app.config) and it has the
    following section in it.
    <configuratio n>
    <appSettings>
    <add key="serv" value="test" />
    </appSettings>
    </configuration>

    I am unable to get the value for key serv in my workbook startup event.

    When I query
    System.Configur ation.Configura tionManager.App Settings("serv" ).tostring, I
    get a message saying that the value is nothig.

    When I query the hasKeys property, I get FALSE.

    I need help on understanding how I can use an external file to pass certain
    parameters to my code.

    I would really appreciate any help I can get.

    Thanks,

    sai


  • Chris

    #2
    Re: Help using appConfig for application settings

    Sai wrote:[color=blue]
    > Hi,
    >
    > I am using VSTO 2005 Beta for building an excel application. I added
    > application configuration file to the project (app.config) and it has the
    > following section in it.
    > <configuratio n>
    > <appSettings>
    > <add key="serv" value="test" />
    > </appSettings>
    > </configuration>
    >
    > I am unable to get the value for key serv in my workbook startup event.
    >
    > When I query
    > System.Configur ation.Configura tionManager.App Settings("serv" ).tostring, I
    > get a message saying that the value is nothig.
    >
    > When I query the hasKeys property, I get FALSE.
    >
    > I need help on understanding how I can use an external file to pass certain
    > parameters to my code.
    >
    > I would really appreciate any help I can get.
    >
    > Thanks,
    >
    > sai
    >
    >[/color]

    Is it really named app.config? It has to be named <Enter Full
    Application Name>.Config

    Chris

    Comment

    • Ken Laws [MSFT]

      #3
      RE: Help using appConfig for application settings

      Hi Sai,

      I created a test VSTO2005 project named "Excel_Conf ig" and was able to
      retrieve a setting from the configuration file by naming the configuration
      file "Excel_Config.d ll.config" and placing it in the debug directory.

      As a reference I've included the XML for the my configuration file below.

      <?xml version="1.0" encoding="utf-8" ?>
      <configuratio n>
      <appSettings>
      <add key="Name" value="Bob"/>
      </appSettings>
      </configuration>

      Using the code below I was able to retrieve the value stored in the "Name"
      key.

      Dim setting As String
      setting = System.Configur ation.Configura tionSettings.Ap pSettings("Name ")
      MessageBox.Show (setting)


      Hope this helps!

      Regards,

      Ken Laws
      MSFT


      This posting is provided "AS IS" with no warranties, and confers no rights.

      For more information regarding Visual Studio Tools for Office 2005:

      Best of Blogs: Visual Studio 2005 Tools for Office
      http://msdn.microsoft.com/library/de...sto2005_ta.asp

      Visual Studio Tools for Office Forum


      Visual Studio Tools for the Microsoft Office System
      http://msdn.microsoft.com/office/und...o/default.aspx

      "Sai" wrote:
      [color=blue]
      > Hi,
      >
      > I am using VSTO 2005 Beta for building an excel application. I added
      > application configuration file to the project (app.config) and it has the
      > following section in it.
      > <configuratio n>
      > <appSettings>
      > <add key="serv" value="test" />
      > </appSettings>
      > </configuration>
      >
      > I am unable to get the value for key serv in my workbook startup event.
      >
      > When I query
      > System.Configur ation.Configura tionManager.App Settings("serv" ).tostring, I
      > get a message saying that the value is nothig.
      >
      > When I query the hasKeys property, I get FALSE.
      >
      > I need help on understanding how I can use an external file to pass certain
      > parameters to my code.
      >
      > I would really appreciate any help I can get.
      >
      > Thanks,
      >
      > sai
      >
      >
      >[/color]

      Comment

      • Jack hu

        #4
        RE: Help using appConfig for application settings

        Sai,

        Why don't you use Settings Designer to create setting. here are some
        example steps

        1. create a VB window Application
        2. Open Settings Designer (Solution Explorer-> My Project -> Setting Tab)
        3. Add your setting (Name='name', Value = 'bob')
        Note: app.config file is generated
        4. to access the setting value, you can use 'My.Setting.Nam e'

        For more information, you can search Help under topic 'Application Setting'

        Good Luck,

        -jack

        Comment

        • Helmut Obertanner

          #5
          RE: Help using appConfig for application settings

          Hello say,

          in VSTO 2005 there exists an Settings.settin gs under your Project Properties.
          this reflects your settings in the app.config file and make it easy to read
          and write.

          in Sourcecode you can acces this settings like this:

          Properties.Sett ings settings = new Properties.Sett ings();
          string someSetting = settings.<NameO fYourSettingHer e>;

          Hope this helps,

          Greets, Helmut



          --
          Helmut Obertanner
          Technical Consultant
          Softwaredevelop ment
          DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich

          .... and IT works!



          "Sai" wrote:
          [color=blue]
          > Hi,
          >
          > I am using VSTO 2005 Beta for building an excel application. I added
          > application configuration file to the project (app.config) and it has the
          > following section in it.
          > <configuratio n>
          > <appSettings>
          > <add key="serv" value="test" />
          > </appSettings>
          > </configuration>
          >
          > I am unable to get the value for key serv in my workbook startup event.
          >
          > When I query
          > System.Configur ation.Configura tionManager.App Settings("serv" ).tostring, I
          > get a message saying that the value is nothig.
          >
          > When I query the hasKeys property, I get FALSE.
          >
          > I need help on understanding how I can use an external file to pass certain
          > parameters to my code.
          >
          > I would really appreciate any help I can get.
          >
          > Thanks,
          >
          > sai
          >
          >
          >[/color]

          Comment

          Working...