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. C# Class Library - Updating Application Settings

C# Class Library - Updating Application Settings

Scheduled Pinned Locked Moved C#
csharpquestionvisual-studiocomtools
3 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.
  • B Offline
    B Offline
    birdman1234
    wrote on last edited by
    #1

    Looking for a workaround :rolleyes: ......I'm trying to update the settings file for a C# class library at runtime. Specifically, I'm trying to update the connectionstring setting for my typed datasets. Microsoft officially doesn't support this functionality in C# (click here) "Because there is no configuration file model for class libraries, application settings do not apply for Class Library projects. The exception is a Visual Studio Tools for Office DLL project, which can have a configuration file." I could create a custom config file but how do I get my typed datasets to reference it?? Thanks, Kevin

    M 1 Reply Last reply
    0
    • B birdman1234

      Looking for a workaround :rolleyes: ......I'm trying to update the settings file for a C# class library at runtime. Specifically, I'm trying to update the connectionstring setting for my typed datasets. Microsoft officially doesn't support this functionality in C# (click here) "Because there is no configuration file model for class libraries, application settings do not apply for Class Library projects. The exception is a Visual Studio Tools for Office DLL project, which can have a configuration file." I could create a custom config file but how do I get my typed datasets to reference it?? Thanks, Kevin

      M Offline
      M Offline
      mikanu
      wrote on last edited by
      #2

      you can always create an XmlDocument object and load up the settings file and make the changes manually. For web applications I know there's a way to change the config file but I'm not sure if it will work in your case. Here's how I did it for my web application: Configuration config = ConfigurationManager.OpenExeConfiguration(""); ConfigurationSection section = config.Sections["connectionStrings"]; // you can use the section information here such as // section.SectionInformation.UnprotectSection(); // then make sure to save the changes to the file config.Save(); and that's it

      ---- www.digitalGetto.com

      B 1 Reply Last reply
      0
      • M mikanu

        you can always create an XmlDocument object and load up the settings file and make the changes manually. For web applications I know there's a way to change the config file but I'm not sure if it will work in your case. Here's how I did it for my web application: Configuration config = ConfigurationManager.OpenExeConfiguration(""); ConfigurationSection section = config.Sections["connectionStrings"]; // you can use the section information here such as // section.SectionInformation.UnprotectSection(); // then make sure to save the changes to the file config.Save(); and that's it

        ---- www.digitalGetto.com

        B Offline
        B Offline
        birdman1234
        wrote on last edited by
        #3

        Thanks for the reply, but that isn't really what I'm looking for. I'm familiar with web configs and the configuration manager. My problem relates to C# class libraries. They don't allow the settings file to be modified at runtime and my typed datasets use the application settings file to determine the connection string. I would like to dynamically set the connection string property based on the application environment at runtime. Cheers.

        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