If you’re trying to set up caching with Code Contracts (and SQL Server CE) but getting errors, then this is the post for you.
On a fresh install of Code Contracts, enabling caching might spawn this error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlServerCe, Version=126.96.36.199, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
This error is telling us that we need SQL Server CE (Compact edition) version 3.5.1, but it lies! What we really need is version 3.5.2.
To fix this error, download and install this (yes, on a 64-bit machine you do need to install both the 32 and 64-bit versions). It’s going to ask you where to extract the files, not where you want to install SQL Server itself; I just chose the desktop.
If you are getting errors such as:
... Schema specified is not valid. Errors:
... error 0175: The specified store provider cannot be found in the configuration, or is not valid
this means you installed the wrong version of SQL Server CE (such as version 3.5.1). To fix this, first uninstall any 3.5.x versions of SQL Server CE, and then download and install what I linked to above.