【问题标题】:Disable web.config schema validation禁用 web.config 架构验证
【发布时间】:2018-01-09 09:54:15
【问题描述】:

我想知道在构建解决方案时是否有办法禁用 web.config 文件的架构验证?我正在使用 Visual Studio 2013。我看到很多类似以下的消息,这有点烦人:

...
Could not find schema information for the element 'loggingConfiguration'
Could not find schema information for the attribute 'name'
Could not find schema information for the attribute 'tracingEnabled'
Could not find schema information for the attribute 'defaultCategory'
...

我知道可以suppress specific warnings,我想知道这类消息是否有类似的东西?

【问题讨论】:

  • 这个问题呢?请告诉我有关此问题的最新信息吗?

标签: .net visual-studio visual-studio-2013 msbuild


【解决方案1】:

我想知道这些消息是否有类似的东西?

这些是来自 Visual Studio 的消息。它们意味着 IDE 无法为我们的部分找到架构,因此 Intellisense 无法使用它们。

通常,这些消息不会影响控件的功能,因此您可以忽略它们。如果对删除 VS 中的所有警告和消息有严格要求,您可以按照以下步骤操作:

  1. 在 Visual Studio 中,打开您的 web.config 文件。
  2. 双击web.config,进入“XML”菜单并选择“Create Schema”。此操作应创建一个名为“web.xsd”的新文件。
  3. 将架构保存在适当的位置(例如,项目的根目录)。
  4. 返回您的web.config 并双击它,查看web.config 文件的“属性”选项卡,其中有一个名为Schemas 的属性。确保您刚刚生成的 xsd 在 Schemas 属性中被引用。如果它不存在然后添加它。

如果您需要进一步的帮助,请重新激活此票:How to fix Error: “Could not find schema information for the attribute/element” by creating schema

【讨论】:

  • 嗨@Leo-MSTF,很抱歉回复晚了。我看到人们建议为 web.config 创建架构的其他帖子,但我期待找到一种更简单的方法来做到这一点,例如使用标志或使用 MSBuild 抑制特定类型的警告。使用您的解决方案意味着我必须将架构文件添加到源代码管理并在每次添加新元素时重新生成它。哦,如果我在解决方案中有多个 web.config 文件,我将不得不多次这样做。
  • @RuiJarimba,如果你有几个web.config,这个方法似乎并不完美。我暂时没有其他更好的解决方案。你有没有尝试过 reexmonkey 的方法:stackoverflow.com/a/14965640/1016343 和 Pressacco:stackoverflow.com/a/7517532/1016343
猜你喜欢
  • 1970-01-01
  • 2010-10-22
  • 2012-05-29
  • 2010-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-18
相关资源
最近更新 更多