question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The type initializer for 'Microsoft.Data.SqlClient.SqlConnection' threw an exception.

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
glucacicommented, Oct 27, 2019

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 and System.Configuration.ConfigurationManager 4.6.0

2reactions
cheenamalhotracommented, Aug 22, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found