The type initializer for 'Microsoft.Data.SqlClient.SqlConnection' threw an exception.
See original GitHub issueDescribe the bug
Exception message: The type initializer for 'Microsoft.Data.SqlClient.SqlConnection' threw an exception.
Stack trace: System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SqlConnection' threw an exception.
---> System.InvalidOperationException: Failed to read the configuration section for enclave providers. Make sure the section is correctly formatted in your application configuration file. Error Message: Configuration system failed to initialize
---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Could not load type 'System.ComponentModel.AsyncCompletedEventArgs' from assembly 'System.Net.WebHeaderCollection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. (/root/HaproxyUpdater2/Config/machine.config)
---> System.TypeLoadException: Could not load type 'System.ComponentModel.AsyncCompletedEventArgs' from assembly 'System.Net.WebHeaderCollection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at System.Configuration.ClientConfigurationHost.OpenStreamForRead(String streamName)
at System.Configuration.Internal.DelegatingConfigHost.OpenStreamForRead(String streamName)
at System.Configuration.ImplicitMachineConfigHost.OpenStreamForRead(String streamName)
at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at Microsoft.Data.SqlClient.SqlConnection..cctor()
--- End of inner exception stack trace ---
at Microsoft.Data.SqlClient.SqlConnection..cctor()
--- End of inner exception stack trace ---
at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString)
To reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
new SqlConnection()
Expected behavior
No exception
Further technical details
Microsoft.Data.SqlClient version: 1.0.19221.1-Preview .NET target: Core 3.0 preview8 SQL Server version: SQL Server 2016 Operating system: Centos7
Additional context
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
type initializer for 'system.data.sqlclient.sqlconnection'? - ...
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. Users who only had just the old version of VMWare View ...
Read more >The type initializer for 'Microsoft.Data.SqlClient. ...
Data.SqlClient.SqlAuthenticationProviderManager' threw an exception. Stack trace: at Microsoft.Data.ProviderBase.DbConnectionPool.
Read more >The type initializer for 'Microsoft.Data.SqlClient. ...
The type initializer for 'Microsoft.Data.SqlClient.SqlAuthenticationProviderManager' threw an exception. We have System.Configuration.
Read more >Receiving error 'The type initializer for 'system.data. ...
Receiving error "The type initializer for 'system.data.sqlclient.sqlconnection' threw an exception." when trying to install Venus 1500 v4; Error:
Read more >The type initializer for 'system.data.sqlclient.sqlconnection ...
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. the following error shows in below line as follows
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
On my PC I also could not reproduced it, but deployed on Windows Server 2016 I get this error. Working version uses
System.Data.SqlClient 4.7.0
andSystem.Configuration.ConfigurationManager 4.6.0
Hi @pengweiqhca
FYI… We were able to identity and fix the issue with “System.Configuration.ConfigurationManager” references for .NET Framework targets and the fix will be available in GA release for 1.0.