More .NET Custom Configuration Madness

Published 09 December 07 04:46 PM | john 

I have to blog about this before I do anything else.  I just found out that if you specify a configSection in your .exe.config file it must come as the first element in the configuration section!  I had done this:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
  <configSections>
    <section name="csr" type="Microsoft.Tools.CodeRunner.Tasks.CsrSection, Microsoft.Tools.CodeRunner, Version=2.0.0.0, Culture=neutral, PublicKeyToken=20af5850399c8643" />
  </configSections>
  <csr>
    <settings>
...
    </settings>
  </csr>
</configuration>

Calling Configuration.GetSection("csr") was resulting in a DefaultSection type an not a CsrSection type.   Moving the startup section after the configSection fixed the problem.  

That's 5 stars on the suck scale in my opinion.

Filed under: , , ,

Comments

No Comments
Anonymous comments are disabled