none
ConfigurationSection.CurrentConfiguration is null RRS feed

  • Question

  • Hi,

    I'm trying to use ConfigurationSection's CurrentConfiguration property to get the top-level Configuration object, after obtaining a ConfigurationSection through ConfigurationManager.GetSection method.

    But CurrentConfiguration returns null.

    Can somebody add some information about this behavior and when and when not to expect the property to have a value?

    Thank you very much.

    Wednesday, March 6, 2013 11:18 AM

Answers

  • In my experience CC is always null if you are getting it via ConfigurationManager.GetSection.  The only time it is set is if you get it through a Configuration object (aka ConfigurationManager.OpenExeConfiguration).  This sort of makes sense because CM doesn't simply wrap a Configuration instance.  So when you're using CM it doesn't go through the same process and ultimately doesn't set CC.  I would recommend that this be reported to MS via Connect so they can resolve it in a future release. 

    Michael Taylor - 3/6/2013
    http://msmvps.com/blogs/p3net

    • Proposed as answer by Mike FengModerator Thursday, March 7, 2013 11:18 AM
    • Marked as answer by mulhacén Thursday, March 7, 2013 12:21 PM
    Wednesday, March 6, 2013 4:15 PM
    Moderator

All replies

  • make sure you are able to get hold of the config file, sometimes you have to point specifically for the file.

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Wednesday, March 6, 2013 11:30 AM
  • In my experience CC is always null if you are getting it via ConfigurationManager.GetSection.  The only time it is set is if you get it through a Configuration object (aka ConfigurationManager.OpenExeConfiguration).  This sort of makes sense because CM doesn't simply wrap a Configuration instance.  So when you're using CM it doesn't go through the same process and ultimately doesn't set CC.  I would recommend that this be reported to MS via Connect so they can resolve it in a future release. 

    Michael Taylor - 3/6/2013
    http://msmvps.com/blogs/p3net

    • Proposed as answer by Mike FengModerator Thursday, March 7, 2013 11:18 AM
    • Marked as answer by mulhacén Thursday, March 7, 2013 12:21 PM
    Wednesday, March 6, 2013 4:15 PM
    Moderator