The configuration element is not declared

后端 未结 9 1465
死守一世寂寞
死守一世寂寞 2020-12-04 17:08

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

         


        
相关标签:
9条回答
  • 2020-12-04 17:44

    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

    0 讨论(0)
  • 2020-12-04 17:47

    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.

    0 讨论(0)
  • 2020-12-04 17:58

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

    Your problem will resolve for sure

    0 讨论(0)
  • 2020-12-04 17:58
    <configuration xmlns="schema URL">
       <!-- configuration settings -->
    </configuration>
    

    do changes,like above & try

    0 讨论(0)
  • 2020-12-04 18:01

    Choose use this schema. DotNetConfig.xsd

    XLM Menu..... Visual Studio

    Works perfectly.

    0 讨论(0)
  • 2020-12-04 18:01

    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.

    0 讨论(0)
提交回复
热议问题