C# 未声明配置元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12523996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The configuration element is not declared
提问by Eae
I'm doing some work in Visual Studio 2012 Express Edition. I have added an App.config XML file as follows:
我正在 Visual Studio 2012 Express Edition 中做一些工作。我添加了一个 App.config XML 文件,如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
The first thing that happens is a warning comes up that says "The 'configuration' element is not declared". Does anyone know why this is happening? It looks like elements can not be declared inside of until this is resolved.
发生的第一件事是出现一个警告,提示“未声明‘配置’元素”。有谁知道为什么会这样?在解决此问题之前,似乎无法在其中声明元素。
Thanks!
谢谢!
This is the entire XML:
这是整个 XML:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Version" value="779" />
<add key="TimeOut" value="60000" />
<add key="LogFileName" value="Log.txt" />
<!-- your Developer Id with eBay -->
<add key="Environment.DevId" value="" />
<!-- your Application Id with eBay -->
<add key="Environment.AppId" value="" />
<!-- your Application Certificate with eBay -->
<add key="Environment.CertId" value="" />
<!-- API Server URL -->
<!-- For production site use: https://api.ebay.com/wsapi -->
<!-- For Sandbox use: https://api.sandbox.ebay.com/wsapi -->
<add key="Environment.ApiServerUrl" value="https://api.sandbox.ebay.com/wsapi" />
<!-- EPS Server URL -->
<!-- For production site use: https://api.ebay.com/ws/api.dll"/-->
<add key="Environment.EpsServerUrl" value="https://api.sandbox.ebay.com/ws/api.dll" />
<!-- eBay Signin URL -->
<!-- For production site use: https://signin.ebay.com/ws/eBayISAPI.dll?SignIn -->
<!-- https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn -->
<add key="Environment.SignInUrl" value="https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn" />
<!-- ViewItem URL -->
<!-- For production site use: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item={0} -->
<add key="Environment.ViewItemUrl" value="http://cgi.sandbox.ebay.com/ws/eBayISAPI.dll?ViewItem&item={0}" />
<!-- token is for both API server and EPS server -->
<add key="UserAccount.ApiToken" value="" />
<!-- eBay site ID -->
<add key="UserAccount.eBayUserSiteId" value="0" />
<add key="logexception" value="true"/>
<add key="logmessages" value="true"/>
<add key="logsdkmessages" value="true"/>
<add key="logsdk" value="true"/>
<add key="logfile" value="Log.txt"/>
<!-- Rule Name-->
<add key="RuName" value=""/>
<!-- Set this if you access eBay API server behind a proxy server-->
<add key="Proxy.Host" value =""/>
<add key="Proxy.Port" value =""/>
<!-- set proxy server username/password if necessary-->
<add key="Proxy.Username" value=""/>
<add key="Proxy.Password" value=""/>
采纳答案by Stephen Scully
I had the same issue. It is not an error, it is simply a warning; so your application should still compile. I used the following simple config file and the warning is still produced.
我遇到过同样的问题。这不是错误,它只是一个警告;所以你的应用程序应该仍然可以编译。我使用了以下简单的配置文件,但仍然会产生警告。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime
version="v4.0"sku=".NETFramework,
Version=v4.5"/>
</startup>
</configuration>
It is an issue that has been raised on the MSDN website, but it does not seem to have been satisfactorily resolved. See link below:
这是MSDN网站上已经提出的问题,但似乎没有得到令人满意的解决。请参阅以下链接:
回答by Ravindra Bagale
<configuration xmlns="schema URL">
<!-- configuration settings -->
</configuration>
do changes,like above & try
做改变,像上面一样并尝试
回答by Ramakrishna
回答by user847335
I had to -> Go to XML menu (visual studio top menu item) choose schemas and select DotNetConfig.xsd AND RazorCustomSchema.xsd AND EntityFrameworkConfig_6_1_0.xsd
我必须 -> 转到 XML 菜单(visual studio 顶部菜单项)选择模式并选择 DotNetConfig.xsd AND RazorCustomSchema.xsd AND EntityFrameworkConfig_6_1_0.xsd
回答by appyCrabby
Visual Studio 2013 Express Edition is missing the DotNetConfig.xsd (https://connect.microsoft.com/VisualStudio/feedback/details/817322/dotnetconfig-xsd-files-not-present-in-vs-2013-express-for-desktop).
Visual Studio 2013 Express Edition 缺少 DotNetConfig.xsd ( https://connect.microsoft.com/VisualStudio/feedback/details/817322/dotnetconfig-xsd-files-not-present-in-vs-2013-express-for-桌面)。
So to get rid of the warning in VS 2013 Express:
因此,要摆脱 VS 2013 Express 中的警告:
- get a copy of DotNetConfig.xsd from another system or from the web (I used https://gist.github.com/eed3si9n/5dd7dd98ad2b3f668928b23477de35a3)
- download to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Xml\Schemas
- add the schema following Ramakrishna's answer
- 从另一个系统或网络获取 DotNetConfig.xsd 的副本(我使用了https://gist.github.com/eed3si9n/5dd7dd98ad2b3f668928b23477de35a3)
- 下载到 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Xml\Schemas
- 在 Ramakrishna 的回答之后添加架构
The warning should be gone.
警告应该消失了。
回答by ashbygeek
I just had this warning popup inside an autogenerated xml file while working on a xaml project.
在处理 xaml 项目时,我刚刚在自动生成的 xml 文件中弹出了这个警告。
Using Debug->Clean Solution and Debug->Rebuild Solution fixed it. Might want to try that before getting fancy with the schemas.
使用 Debug->Clean Solution 和 Debug->Rebuild Solution 修复它。可能想在看中模式之前尝试一下。
回答by Felipe R Valera
Choose use this schema. DotNetConfig.xsd
选择使用此架构。点网配置文件
XLM Menu..... Visual Studio
XLM 菜单..... Visual Studio
Works perfectly.
完美运行。
回答by Vallabh
I was having less space on my drive which might have resulted in incomplete loading of my application solution. This "the-configuration-element-is-not-declared" problem got solved after i created some space on my drive.
我的驱动器上的空间较少,这可能导致我的应用程序解决方案加载不完整。在我在驱动器上创建了一些空间后,这个“未声明的配置元素”问题得到了解决。


