The configuration section can not contain a text element or CDATA

2

The error began to appear when I added the variable:

 <add key="Teste" value="true"/>

Entire App.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <appSettings>
   <add key="Teste" value="true"/>
     </appSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="x86"/>
    </assemblyBinding>
  </runtime>
</configuration>

C #:

if (Convert.ToBoolean(ConfigurationManager.AppSettings["Teste"]))

Does anyone know what it can be? Thanks.

    
asked by anonymous 05.06.2018 / 20:22

1 answer

0

I've done some tests here and in its section appSettings is coming up with a blank space and this is causing the error as there is a text element in the section, white space. see the image below

Afterremovingthisspace,theerrorhasstoppedhappening

SeemoreaboutCDATAhere: What is used for

    
05.06.2018 / 20:43