How to use Configure class to access "my own" configuration file

Last post 05-08-2008 9:35 PM by aliasncnu. 6 replies.

Sort Posts:

  • How to use Configure class to access "my own" configuration file

    04-28-2008, 5:48 AM
    • Member
      148 point Member
    • aliasncnu
    • Member since 03-18-2007, 10:08 AM
    • Taiwan
    • Posts 333

    Hi,

    I designa config file, says my.config, separated from web.config for not cluttering web.config. I hope that I can still use Configure Class to aceess the my.config, instead of using low-level XML API to parse it!

    Is this scenario possible to implement?

    Any suggestion is welcome.

    Ricky.

    Take nothing on looks; take everything on evidence.
    - Charles Dickens
  • Re: How to use Configure class to access "my own" configuration file

    04-28-2008, 8:34 AM
    Answer
    • All-Star
      79,130 point All-Star
    • jeff@zina.com
    • Member since 09-26-2003, 10:43 AM
    • Naples, FL, USA
    • Posts 10,751
    • Moderator
      TrustedFriends-MVPs

    First, don't do this.  The web.config is designed to be "cluttered" with your settings.  Use comments in it iof you wish to organize it.  That said, you can reference external files if you wish:

    http://www.devx.com/vb2themax/Tip/18880
    http://www.beansoftware.com/ASP.NET-Tutorials/Multiple-Config.aspx

    Jeff

    Blatant Self Promotion: ASP.NET 3.5 CMS Development
  • Re: How to use Configure class to access "my own" configuration file

    04-28-2008, 9:42 AM
    • Member
      148 point Member
    • aliasncnu
    • Member since 03-18-2007, 10:08 AM
    • Taiwan
    • Posts 333

    Hello, the external appSettings is not perfectly suitable for my situation. I will define hierarchial structure as

    <a>

    <b name="..."  friendlay="..." value="..." />

    <b name="..."  friendlay="..." value="..." />

    </a>

    Do you know any more complex mechanism to access this kind of xml with objects  armed with strong-typed properties like Configuration class?

    Regards,

    Ricky.

    Take nothing on looks; take everything on evidence.
    - Charles Dickens
  • Re: How to use Configure class to access "my own" configuration file

    05-03-2008, 11:30 PM
    Answer

    aliasncnu:

    <a>

    <b name="..."  friendlay="..." value="..." />

    <b name="..."  friendlay="..." value="..." />

    </a>

    Hi Ricky,

    For the specific config section as you provided, we need to create corresponding configuration section handler for it. Please refer to following link to learn how to create a custom configuration section handler for your own configuration section.

    How To Create a Custom ASP.NET Configuration Section Handler in Visual C# .NET
    http://support.microsoft.com/kb/309045

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
  • Re: How to use Configure class to access "my own" configuration file

    05-04-2008, 8:38 PM
    • Member
      148 point Member
    • aliasncnu
    • Member since 03-18-2007, 10:08 AM
    • Taiwan
    • Posts 333

    Hi,
    I have read similar topic you provided. Do you know how to extend this mechanism to my own config file instead of web.config?

    Thanks,
    Ricky.

    Take nothing on looks; take everything on evidence.
    - Charles Dickens
  • Re: How to use Configure class to access "my own" configuration file

    05-07-2008, 7:30 AM
    • Member
      88 point Member
    • Wulfy
    • Member since 09-04-2002, 9:41 AM
    • Posts 27

    I would also be really interested in such a solution.  I already have custom sections in web.config loading settings into the web application via Configuration Section Handlers, now I would like to move the xml configuration into a separate file.  Has anyone achieved this?  It seems like the file/configSource attribute only exists for the inbuilt config sections such as appSettings etc...?

    Thanks

    James

  • Re: How to use Configure class to access "my own" configuration file

    05-08-2008, 9:35 PM
    • Member
      148 point Member
    • aliasncnu
    • Member since 03-18-2007, 10:08 AM
    • Taiwan
    • Posts 333

    Hello, James

    I have posted a workaround on http://www.codeproject.com/KB/aspnet/AddCustomConfigSections.aspx.

    Hope it help! Regrads,

    Ricky

    Take nothing on looks; take everything on evidence.
    - Charles Dickens
Page 1 of 1 (7 items)