2009-11-13 51 views
2

我在我的web.config中創建了自定義標記。我首先在configSections部分下寫了以下條目。無法找到元素「城堡」的架構信息

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

但是,當我嘗試創建配置節點內城堡節點如下

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

我收到以下錯誤信息:」 *找不到架構信息元素'**城堡'*。「 「***找不到元素'**組件'***的模式信息。」

我錯過了什麼嗎?我找不到原因。而且,如果我想運行應用程序時,我得到以下錯誤「無法與此域相關的配置文件中找到部分中的‘城堡’。

Ps.//樣品來自「臨ASP.NET MVC框架 「/史蒂芬·桑德森/ A按ISBN-13(PBK):978-1-4302-1007-8」 第99頁。

上感謝您的幫助

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

因爲我相信已經完成正是這本書所說的並沒有成功,我用不同的術語提出了同樣的問題。 如何使用上述信息添加新節點?

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

謝謝。我做了你所說的,沒有兩個警告。不過,我去一個大的新的警告:

「元素命名空間‘MyWindsorSchema’'配置具有無效的子元素‘configSections’命名空間‘MyWindsorSchema’的可能名單預期的元素:'包含名稱空間'MyWindsorSchema'中的屬性,設施,組件'。「

回答

2

你得到的不是一個會阻止你運行你的應用程序的錯誤。這只是Visual Studio發出的警告,因爲它不知道配置文件中的castle節點。您可以使用架構來啓用智能感知。下載Castle Windsor Schema文件,並看看裏面的readme.txt。它告訴你把windsor.xsd放在硬盤的某個地方,然後在配置文件中引用它:

<?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>