Unrecognized element 'type' Reading Unity Configuration

Feb 10, 2010 at 2:26 PM

my app config looks like

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
  </configSections>
<unity>
    <containers>
      <container name="Base">             
          <types>
          <type type="Platform.Utility.Logging.ILoggingTools, Platform.Utilities"
                mapTo="Platform.Utility.Logging.InjectedLogger, Platform.Utilities"
                lifetime="Singleton" name="Logger" />
        </types>
      </container>
     </containers>
  </unity>

When I attempt to:

    object sectionObj = ConfigurationManager.GetSection("unity");
            var section = (UnityConfigurationSection) sectionObj;
            return section;

I get the following exception:

System.Configuration.ConfigurationErrorsException: Unrecognized element 'type'

 

Feb 10, 2010 at 5:10 PM

There is one thing wrong I can see right off the bat - lifetime is a nested element, not an attribute. Nothing else obviously jumps out. Does the error message give you a line number in the config file for the error?

 

Feb 10, 2010 at 5:23 PM

ctaveres,

Thanks for the response.  Yea, I discovered that too.  The problem with the unrecognized element error was a problem in a configuration of a different container (other than the one I posted).  I had forgotten my <types> section around the type declarations.

Its usually the small stuff that gets me <g>

 

Thanks.