Error when trying to connect to SQL Server

If you come across this fine error:


It is likely because somehow, over time, you’ve installed many or multiple versions of SQL Server Compact Edition.  This was, at times called different names such as SQL Server Anywhere and SQL Server 2005 Mobile Edition.

To remedy the situation, it’s as easy as 1-2-3-4:

1. open explorer and go to: C:\Windows\Microsoft .Net\Framework\v.<whatever is in the error message, e.g. 2.0.xxxxx>\Config

2. Make a back up of the machine.config file, then open it in a text editor (e.g Notepad)

3. Search for "Invariant"

4. Remove duplicate entries where InvariantName = "System.Data.SqlServerCe".  Note: ensure the duplicate entries have the same public key value.  If they differ, then you have to figure out which version is valid, which is outside the scope of this post.

You’ll have to restart any application which make use of ADO/ODBC connections (e.g. Visual Studio, SQL Management Studio) but you should be OK now.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.