The \"rest of the story\" is told below in all its gory details, but to cut to the chase, it comes down to this:
SQLCE 2.0 (contained in sqlce.wce4.armv4.CAB) seems
Yes, you have a mismatch.
You have a database file that internally indicates that it is a SQL Compact 2.0 file.
You have a System.Data.SqlServerCe.dll assembly that is version 3.5.1. The "runtime version" means what CF runtime was it built against, so it was built against the 2.0 runtimes - it doesn't mean that it is 2.0 itself. This was the point of confusion - you kept naming two versions and an assembly has only one version.
This was my suspicion because you're calling Upgrade()
which doesn't even exist in SQL Compact 2.0.
If you want to open the original database, in it's original state, and allow it to still be accessible by the original creator (and there has to be code that creates it or it's deployed already-built in a CAB file, there's no implicit way it could happen) then one again I reiterate, you must use the same version of SQL Compact to do so.
In your specific case what this means is that you should do the following:
You do not need to call Upgrade()
unless you want to make it a 3.5 database, at which point you can't go back, plus you'll be trying to upgrade every time you run, which I doubt is what you want anyway. That method is generally for utilities or one-time use.
It doesn't matter how many other versions of the assemblies are on your PC, and in fact you can have multiples on the device too. The important thing is that what you have in your project reference, meaning what the app is linked to, is the same DLL that gets loaded by the application on the device when it actually executes.
Generally I do 2 things to make sure this happens: