web.config中,configSource和"在'XXX'元素未声明"警告 [英] web.config, configSource, and "The 'xxx' element is not declared" warning

查看:1175
本文介绍了web.config中,configSource和"在'XXX'元素未声明"警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经破裂的可怕的笨拙的web.config文件到使用configSource属性,对一些路段的单个文件(例如是connectionStrings,认证,网页等)。

I have broken down the horribly unwieldy web.config file into individual files for some of the sections (e.g. connectionStrings, authentication, pages etc.) using the configSource attribute.

这是工作的罚款,但持有VS.节'片断'事业警告单独的XML文件

This is working fine, but the individual xml files that hold the section 'snippets' cause warnings in VS.

例如,用于角色管理器部分名为roleManager.config文件,如下所示:

For example, a file named roleManager.config is used for the role manager section, and looks like this:

<roleManager enabled="false">
</rolemanager>

不过,我得到的VS元素roleManager下一个蓝色的Squiggle和以下警告:在'roleManager'元素未声明

我猜这是什么做有效的XML和模式等是否有一种简单的方法来解决这个问题?我的东西可以添加到单个文件?

感谢

P.S。我听说,这是不好的做法,打破了web.config文件会是这样。但真的不明白,为什么? - 任何人都可以照亮我

P.S. I have heard that it is bad practice to break the web.config file out like this. But don't really understand why - can anyone illuminate me?

推荐答案

搜索的解决方法,使用自定义配置文件这件事,我发现了这个解决方案。不知道是否是正确的。

Searching a workaround to this matter using Custom Config Files, I found this solution. Dont know if is the correct one.

问题是,VS不能找到一个模式来验证您的.config(XML)。如果使用的是原生的配置元素,或当您创建自定义.config文件,您必须设置为每个XML文档的模式。

The problem is that VS cant find a schema to validate your .config (xml). If you are using "native" configuration elements or when you create your custom .config files you must set to every xml document a schema.

默认情况下(在VS9为例)所有的XML文件使用\\微软的Visual Studio 9.0 \\ XML \\架构\\ DotNetConfig.xsd
但您可以添加更多的模式来使用。

By default (in VS9 for example) all xml files use \Microsoft Visual Studio 9.0\Xml\Schemas\DotNetConfig.xsd but you can add more schemas to use.

分配模式之前,你必须创建它。

Before assigning a schema you must create it.

要根据自己的custom.config创建一个新的模式:


  1. 打开您的自定义配置文件

  2. 在菜单栏XML->创建模式

  3. 保存

要分配架构:


  1. 打开您的自定义配置文件

  2. 在属性面板:点击浏览按钮[..]

  3. 在使用列设置为您最近创建的模式

您可以分配尽可能多的你想要的。或者有一个模式为您的所有不同的自定义.config文件

you can assign as many you want. or have one schema for all your different custom .config files

(很抱歉,但我的英语不太好)

(Sorry, but my English is not so good)

这篇关于web.config中,configSource和&QUOT;在'XXX'元素未声明&QUOT;警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆