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 files

Configuration files

Scheduled Pinned Locked Moved C#
questionworkspace
5 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.
  • P Offline
    P Offline
    peshawarcoder
    wrote on last edited by
    #1

    Hi! I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly. But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file. So when i add that data to the web.config file it works fine. But i want my objects be able to read configuration data from the app.config file. How can i do that? Thanks.

    R D 2 Replies Last reply
    0
    • P peshawarcoder

      Hi! I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly. But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file. So when i add that data to the web.config file it works fine. But i want my objects be able to read configuration data from the app.config file. How can i do that? Thanks.

      R Offline
      R Offline
      Rick van Woudenberg
      wrote on last edited by
      #2

      Hi peshawarcoder, To me, this sounds like a permission problem / path problem. Could you post the error that it gives ? Cheers,

      1 Reply Last reply
      0
      • P peshawarcoder

        Hi! I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly. But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file. So when i add that data to the web.config file it works fine. But i want my objects be able to read configuration data from the app.config file. How can i do that? Thanks.

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

        Class libraries cannot have config files. They are libraries of code that become part of the application project itself. Using the normal built-in methods, they must get their settting from the host applications config files, be it app.config for WinForms or web.config for ASP.NET. Outside of that, you'll have to implement your own configuration settings retrieval scheme.

        Dave Kreskowiak Microsoft MVP - Visual Basic

        P 1 Reply Last reply
        0
        • D Dave Kreskowiak

          Class libraries cannot have config files. They are libraries of code that become part of the application project itself. Using the normal built-in methods, they must get their settting from the host applications config files, be it app.config for WinForms or web.config for ASP.NET. Outside of that, you'll have to implement your own configuration settings retrieval scheme.

          Dave Kreskowiak Microsoft MVP - Visual Basic

          P Offline
          P Offline
          peshawarcoder
          wrote on last edited by
          #4

          Thanks. Your suggestion to implement my own configuration setting retrieval scheme will help me to a great extent. Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file. (I have already done this.) But i want that there should be a separate configuration file from which objects instantiated from the classes in the class library get thier data.

          D 1 Reply Last reply
          0
          • P peshawarcoder

            Thanks. Your suggestion to implement my own configuration setting retrieval scheme will help me to a great extent. Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file. (I have already done this.) But i want that there should be a separate configuration file from which objects instantiated from the classes in the class library get thier data.

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

            peshawarcoder wrote:

            Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file

            No. You implement your own configuration manager so that your code can specify which file to open to get configation settings. You can probably start with this[^].

            Dave Kreskowiak Microsoft MVP - Visual Basic

            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