configuration file of castle windsor

2019-07-16 03:11发布

问题:

that how my config file looklike:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <!--<configSections>
    <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" />
  </configSections>
  <castle>-->
    <components>
      <component id="BasicElement" service="ClassLibrary1.ISomething, ClassLibrary1"
                 type="ClassLibrary1s.Something, ClassLibrary1"
                 lifestyle="singleton">
      </component>
    </components>
  <!--</castle>-->
</configuration>

when I run my application in F5 i got the error: Configuration system failed to initialize, and the inner exception tells me: Unrecognized configuration section components.

and i see that it consequentially call the file Interception.vshost.exe.Config although that I explicitly asked him to read other file.

please help!!!

回答1:

You've commented out the configSection part and the castle parts leaving just the component section.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" />
  </configSections>
  <castle>
    <components>
    </components>
  </castle>
</configuration>

If you want a blank castle configuration I would suggest something like the above.