C# – Could not find schema information for the element ‘castle’

asp.net-mvcccastle-windsorweb.config

I'm creating a Custom tag in my web.config. I first wrote the following entry under the configSections section.

<section name="castle"
           type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,
         Castle.Windsor" />

But, when I try to create a castle node inside the configuration node as below

<castle>
    <components>
    </components>
</castle> 

I get the following error message:"*Could not find schema information for the element '**castle'*." "***Could not find schema information for the element '**components'***."

Am I missing something? I can't find why. And, if I run the application anyway, I get the following error "Could not find section 'Castle' in the configuration file associated with this domain."

Ps.// The sample comes from "Pro ASP.NET MVC Framework"/Steven Sanderson/APress ISBN-13 (pbk): 978-1-4302-1007-8" on page 99.

Thank you for the help

============================================================

Since I believe to have done exactly what's said in the book and did not succed, I ask the same question in different terms. How do I add a new node using the above information?

=============================================================================

Thank you. I did what you said and do not have the two warnings. However, I've go a big new warning:

"The element 'configuration' in namespace 'MyWindsorSchema' has invalid child element 'configSections' in namespace 'MyWindsorSchema'. List of possible elements expected: 'include, properties, facilities, components' in namespace 'MyWindsorSchema'."

Best Answer

What you get is not an error that will prevent you from running your application. It is just a warning that Visual Studio emits because it does not know the castle node in a config file. You could use a schema to enable intellisense. Download the Castle Windsor Schema file and take a look at the readme.txt inside. It tells you to put windsor.xsd somewhere on your hard drive and then reference it in the config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="MyWindsorSchema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="MyWindsorSchema file://S:\Common\Windsor\windsor.xsd">

    <configSections>
        <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" />
    </configSections>

    <castle>
        <components>
        </components>
    </castle>
</configuration>