I couldn\'t figure out what is the problem for this exception.
The type initializer for \'System.Data.SqlClient.SqlConnection\' threw an exception
I've read a lot about this issue, but no one has mentioned the following cause of this error.
Some of our users, who had an older version of VMWare View Client which was then upgraded, are now seeing this issue.
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception
We did attempt to reinstall .Net Framework and Visual Studio Tools for Office, but this didn't fix anything.
We haven't found a fix yet, but I hope this helps other users.
Btw, we did check our app.config's and web.config's, and these are all fine (and work perfectly with the rest of our users).
One other discovery:
So... we're now stuck.
I have a test laptop, and I can reproduce the error everytime when my user ID doesn't have Local Admin rights. If we then grant Local Admin rights, and I log in again, the error goes away.
And I added a load of try..catch's in my code, and found that the exception occurs in this one line of code:
MikesDataContext dc = new MikesDataContext()
So, it's actually making the connection which throws the exception. It does not get as far as the next lines of code which use this connection.