Error starting WPF application

2

When I start my application, an error message is displayed. The problem is that I can not find the source of the problem. Before, it did not start today. I thought it might be some configuration, but I did not change anything in Visual Studio, which reminds me. Visual Usage 2017 (Portuguese) and WPF. See the image of the error below:

HereismyApp.Config

<?xmlversion="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="inetConn" connectionString="Data Source=NOTEBOOK\Instancia; Initial Catalog=SILOS; User Id=sa; Password=@d123" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>
    
asked by anonymous 11.08.2017 / 15:44

1 answer

0

The exception says:

  

ConfigurationErrorsException: Only one element is allowed per configuration file and, if present, must be the first child of the element

Update if config by putting <configSections> before <connectionStrings> , thus:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="inetConn" connectionString="Data Source=NOTEBOOK\Instancia; Initial Catalog=SILOS; User Id=sa; Password=@d123" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>
    
11.08.2017 / 15:48