The type initializer for ‘System.Data.SqlClient.SqlConnection’ threw an exception

I was getting the above error in one of my windows application. Was because of some section getting repeated in the app.config file.

Removing the duplicate section information from the app.config resolved the issue.


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

5 thoughts on “The type initializer for ‘System.Data.SqlClient.SqlConnection’ threw an exception”

  1. I just received the exact same error, only mine wasn’t a duplicate section in the app.config. Mine was due to the appSettings section being above my connectionStrings section. Strange, and yeah it makes no sense, but I moved the appSettings to the bottom via cut-paste and the exception goes away.

    Like

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s