0

I came for advice.I'm trying to connect to the database through C#.But I have a problem with the App config file.It keeps throwing the App exception:,,

Configuration system failed to initialize

".I tried to add ,as advised here:Configuration System Failed To Initialize , but with no positive result. So I wonder,if there is still a problem in the code,but I rather think that the problem is with the App config file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    
    <add key="DataSource" value=" My Database'IP adress "/>
    <add key="Database" value="My database Name"/>
    <add key="Name" value="User name"/>
    <add key="Password" value="Password"/>
    
</configuration>


  

1 Answers1

0

It seems like you're missing the appSettings element that wraps your key-value collection. It should look more like the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="DataSource" value=" My Database'IP adress "/>
    <add key="Database" value="My database Name"/>
    <add key="Name" value="User name"/>
    <add key="Password" value="Password"/>
  </appSettings>
</configuration>
AlwaysLearning
  • 7,915
  • 5
  • 27
  • 35