The configuration element is not declared

C#XmlApp Config

C# Problem Overview


I'm doing some work in Visual Studio 2012 Express Edition. I have added an App.config XML file as follows:

<?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 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&amp;item={0} -->
<add key="Environment.ViewItemUrl" value="http://cgi.sandbox.ebay.com/ws/eBayISAPI.dll?ViewItem&amp;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=""/>

C# Solutions


Solution 1 - C#

Go to XML menu (visual studio top menu item) choose schemas and find for DotNetConfig.xsd and choose Use this schema.

XML - Schemas

Edit XML Schema

Your problem will resolve for sure

Solution 2 - C#

<configuration xmlns="schema URL">
   <!-- configuration settings -->
</configuration>

do changes,like above & try

Solution 3 - C#

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:

http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/18a1074f-668f-4fe3-a8d9-4440db797439

Solution 4 - C#

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

Solution 5 - C#

I just had this warning popup inside an autogenerated xml file while working on a xaml project.

Using Debug->Clean Solution and Debug->Rebuild Solution fixed it. Might want to try that before getting fancy with the schemas.

Solution 6 - C#

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).

So to get rid of the warning in VS 2013 Express:

The warning should be gone.

Solution 7 - C#

Choose use this schema. DotNetConfig.xsd

XLM Menu..... Visual Studio

Works perfectly.

Solution 8 - C#

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.

Solution 9 - C#

I also got the same warning. After thinking about for some time I realized my error working with SQL (MS SQL).

Warning: the 'configuration' element is not declared

Using C#

App.Config code:

<connectionStrings>
    <add name="dbx" connectionString="Data Source=ServerNameHere;Initial Catalog=DatabaseNameHere;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

*this calls out the database name in the connectionStrings, when I plugged in my SQL code as a practice I always use the database name, schema, then table. This practice didn't carry over well in Visual Studio as I am a beginner. I removed the db name from my SQL syntax and only called from the schema, data table. This resolved the issue for me.

Form.CS:

 using (SqlCommand cmd = new SqlCommand("SELECT * FROM [DatabaseName].[Schema].[TableName] WHERE [MEPeriod] = '2020-06-01'", con))

Updated to:

using (SqlCommand cmd = new SqlCommand("SELECT * FROM [Schema].[TableName] WHERE [MEPeriod] = '2020-06-01'", con))

This worked for me, I hope this is found as useful.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEaeView Question on Stackoverflow
Solution 1 - C#RamakrishnaView Answer on Stackoverflow
Solution 2 - C#Ravindra BagaleView Answer on Stackoverflow
Solution 3 - C#Stephen ScullyView Answer on Stackoverflow
Solution 4 - C#user847335View Answer on Stackoverflow
Solution 5 - C#ashbygeekView Answer on Stackoverflow
Solution 6 - C#appyCrabbyView Answer on Stackoverflow
Solution 7 - C#Felipe R ValeraView Answer on Stackoverflow
Solution 8 - C#VallabhView Answer on Stackoverflow
Solution 9 - C#KennethView Answer on Stackoverflow