I am currently working on a simple app using Ms Sql and VSC# desktop app. Then this occurs:
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception
I tried figuring out how to solve it but to no avail. I already tried adding this as the first child of configuration tag in app.config
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="YourProjectName.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
Still it didnt work. Then I remembered that if you install vmware or XAMPP and MS Sql Management studio, this error occurs. Isnt there any other way to make these two work without uninstalling the other?
UPDATE: I tried the 'self-enclosing tag' of add and this happened
this is my whole config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ToDoListDesktopMsSql.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<add name="TodoContext" providerName="System.Data.SqlClient"
connectionString="Data Source=QLYNE-PC\QLYNESQL; Initial Catalog=ToDoListDb; integrated security = true;"
/>
</configuration>