0

I am trying to read a Microsoft defined ConfigurationSection:

Microsoft.ApplicationServer.Caching.DataCacheClientSection

but the type is internal so I cannot access it in the conventional way.

i.e.

var dataCacheClientSection = (DataCacheClientSection)ConfigurationManager.GetSection("dataCacheClient");

I know I can use reflection but do I have any other options?

Paul Hiles
  • 9,558
  • 7
  • 51
  • 76

1 Answers1

1

You can open the configuration file as XmlDocument and read whatever you want there using XPath.

Something like:

var xmlDoc = new XmlDocument();
xmlDoc.Load(Assembly.GetExecutingAssembly().Location + ".config");
XmlNode setting = xmlDoc.SelectSingleNode("configuration/...");

Use the correct XPath in SelectSingleNode

ElDog
  • 1,230
  • 1
  • 10
  • 21