我正在web.config中创建一个自定义标记。我首先在configSections部分下写了下面的条目。
<section name="castle"
type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,
Castle.Windsor" />
但是,当我尝试在配置节点内创建一个城堡节点时,如下所示
<castle>
<components>
</components>
</castle>
我得到以下错误消息:“*未能找到元素的架构信息”*无法找到元素‘**components’*的模式信息。
我是不是遗漏了什么?我找不到原因。而且,如果我无论如何运行该应用程序,我会得到以下错误:“无法在与此域关联的配置文件中找到‘城堡’部分。”
Ps.//示例来自"Pro ASP.NET MVC框架“/Steven Sanderson/APress ISBN-13 (pbk):978-1-4302-1007-8”,第99页。
谢谢你的帮助
============================================================
因为我相信我做了书中所说的,但没有成功,所以我用不同的术语问了同样的问题。如何使用上述信息添加新节点?
=============================================================================
谢谢。我照你说的做了,没有收到这两次警告。然而,我要提出一个新的警告:
“名称空间'MyWindsorSchema‘中的元素’MyWindsorSchema‘中的元素'configSections’在名称空间'MyWindsorSchema'.列表中具有无效的子元素‘configSections’,这些元素被期望在名称空间‘MyWindsorSchema’中包含、属性、设施、组件。”
发布于 2009-11-13 07:35:54
您所得到的并不是一个会阻止您运行应用程序的错误。这只是Visual发出的警告,因为它不知道配置文件中的castle
节点。可以使用架构来启用intellisense。下载城堡温莎模式文件并查看其中的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>
https://stackoverflow.com/questions/1727419
复制相似问题