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. Config file in dll project?

Config file in dll project?

Scheduled Pinned Locked Moved C#
question
3 Posts 3 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.
  • D Offline
    D Offline
    davebarkshire
    wrote on last edited by
    #1

    I want to keep a connection string in a config file in a DLL project. I have tried using myappname.dll.config and app.config and have stored the data like this... and try to retrieve this data using... strConnectionString = ConfigurationSettings.AppSettings["constring"]; I'm only getting null back. The application doesn't seem to be able to see the config file. ConfigurationSettings.AppSettings.Keys.Count is zero. ConfigurationSettings.AppSettings.Count is zero. Can anyone tell me why this is not working? Thanks in advance - Dave

    D D 2 Replies Last reply
    0
    • D davebarkshire

      I want to keep a connection string in a config file in a DLL project. I have tried using myappname.dll.config and app.config and have stored the data like this... and try to retrieve this data using... strConnectionString = ConfigurationSettings.AppSettings["constring"]; I'm only getting null back. The application doesn't seem to be able to see the config file. ConfigurationSettings.AppSettings.Keys.Count is zero. ConfigurationSettings.AppSettings.Count is zero. Can anyone tell me why this is not working? Thanks in advance - Dave

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      Configuration files seems to be intended for applications, not for libraries. ConfigurationSettings is just a wrapper around XmlDocument You can easily write your own (and provide abstract API, so you can extend or re-implement it in case you figure out some better way how to do it). David Never forget: "Stay kul and happy" (I.A.)
      David's thoughts / dnhsoftware.org / MyHTMLTidy

      1 Reply Last reply
      0
      • D davebarkshire

        I want to keep a connection string in a config file in a DLL project. I have tried using myappname.dll.config and app.config and have stored the data like this... and try to retrieve this data using... strConnectionString = ConfigurationSettings.AppSettings["constring"]; I'm only getting null back. The application doesn't seem to be able to see the config file. ConfigurationSettings.AppSettings.Keys.Count is zero. ConfigurationSettings.AppSettings.Count is zero. Can anyone tell me why this is not working? Thanks in advance - Dave

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Because .DLL projects can't have config files. Since the .DLL becomes part of the host application using it, any code you write like this in the .DLL will use the host applications config file. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        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