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
    • Loading...
    • aliasncnu
    • Joined on 03-18-2007, 10:08 AM
    • Posts 253

    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.

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

    04-28-2008, 8:34 AM
    Answer

    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

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: How to use Configure class to access "my own" configuration file

    04-28-2008, 9:42 AM
    • Loading...
    • aliasncnu
    • Joined on 03-18-2007, 10:08 AM
    • Posts 253

    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.

  • 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 click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. 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
    • Loading...
    • aliasncnu
    • Joined on 03-18-2007, 10:08 AM
    • Posts 253

    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.

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

    05-07-2008, 7:30 AM
    • Loading...
    • Wulfy
    • Joined on 09-04-2002, 9:41 AM
    • Posts 24

    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
    • Loading...
    • aliasncnu
    • Joined on 03-18-2007, 10:08 AM
    • Posts 253

    Hello, James

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

    Hope it help! Regrads,

    Ricky

Page 1 of 1 (7 items)