Which SqlServerCe DLL version do I need to reference in my project to match what's in sqlce.wce4.armv4.CAB?

后端 未结 1 437
旧巷少年郎
旧巷少年郎 2020-12-22 10:31

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

相关标签:
1条回答
  • 2020-12-22 11:19

    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:

    1. Change the project reference (this means in Studio, on your PC) to point to a System.Data.SqlServerCe.dll that has an assembly version of 2.0.xxx.
    2. Make sure that the device has the exact same version (2.0.xxx) numbered SQL Compact files on it. This includes System.Data.SqlServerCe.dll as well as all of the sscexx.dll native files. There are about a half dozen.

    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:

    1. Put all of the SQL CE stuff right into the app folder on the device, not distributed via CAB but deploy each individual file, to make sure this is what happens.
    2. Reference directly to the file on your PC. Don't use Studio's "magic" method of finding a .NET reference, but browse directly to the System.Data.SqlServerCe.dll you know is right and add the reference that way.
    0 讨论(0)
提交回复
热议问题