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
- Users who only had just the old version of VMWare View Client installed have no problem.
- Users who only had just the new version of VMWare View Client installed have no problem.
- But users who had an old version of VMWare View Client, but have now been upgraded, do have a problem, and it does continue even if we uninstall VMWare View Client, then install the new version.
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:
- If your user has local admin rights, this problem doesn't occur after upgrading VMWare View Client.
- If they don't have local admin rights, the issue will occur.
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.