Error when trying to connect to SQL Server


If you come across this fine error:

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.


About Rob Sanders

IT Professional and TOGAF 9 certified architect with nearly two decades of industry experience, 18 years in commercial software development and 11 years in IT consulting. Check out the "About Rob" page for more information.

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>