如何解决“'配置'元素未在C#.net中声明为”警告消息

问题描述 投票:8回答:3

从我的app.config文件生成的这个警告让我发疯,我一直在搜索,但没有得到任何真正的答案,为什么会这样。这是代码。

任何帮助将不胜感激

c# app-config compiler-warnings
3个回答
16
投票

我通过编辑C:\ Program Files(x86)\ Microsoft Visual Studio 12.0 \ Xml \ Schemas \ catalog.xml修复了VS2013和.NET 4.6目标项目的问题。

我修改了现有的行:

<Association extension="config" schema="%InstallRoot%/xml/schemas/%LCID%/dotNetConfig.xsd"   condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.5.') or $TargetFrameworkMoniker = ''" />

<Association extension="config" schema="%InstallRoot%/xml/schemas/%LCID%/dotNetConfig.xsd"   condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.5.') or starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.6')" />

在app.config和web.config文件中关闭并重新打开VS2013和intellisense再次开始工作(使用.NET 4.6定向项目)。


6
投票

在VS的主菜单中,选择XML> Schemas ...在弹出的窗口中,找到DotNetConfig.xsd的条目(应该是第一项),并在该条目的Use列中选中复选标记。然后单击确定。


0
投票

我有同样的问题,这解决了它:

从Visual Studio菜单中,单击XML> Schemas ...

寻找DotNetConfig.xsd

确保选中“使用此架构”

'好'

© www.soinside.com 2019 - 2024. All rights reserved.