If one. NET applications to be adaptive to 32-bit/64-bit systems, simply set the project's target platform to "any CPU". However, if you use SQLite in your application, the situation is different.
SQLite's. NET development package comes from the System.Data.SQLite, which completes the compatible ADO, and also provides the LINQ and entity Framework 6 implementations. But it doesn't matter, it's important that System.Data.SQLite is made up of two parts of code, part of unmanaged C + + code, and some managed code. NET Framework interface. Since unmanaged code cannot be built as an "any CPU", each packet of the System.Data.SQLite download page is differentiated by a 32-bit or 64-bit system.
Speaking of which, by the way, look at the download page System.Data.SQLite dizzy. Although the download page at the beginning of a lot of space to explain how to choose to download, but it is estimated that few people will read it, so here is a brief introduction.
1) First, the binary packages are divided into installation packages, non-statically connected binary packages, and statically connected binaries by type. The installation package installs the relevant dynamic library into the system and registers it with the GAC (Global Assembly Cache), the difference between the two binary packages is that the unmanaged parts are connected differently, and non-statically connected binary packages require the support of the VC runtime Library when they are used. It is important to note that if you need to connect to the SQLite database in Visual Studio, you must select the appropriate installation package to install .
For example, to connect SQLite in Visual Studio 2010, you should download "sqlite-netfx40-setup-bundle-x86-2010-1.0.90.0.exe", This is specified in the description of the download package in bold text.
[The description of the download package has a clear description of bold words]
After installation, you can connect SQLite in Visual Studio 2010:
[Connect to SQLite in Visual Studio]
2) Each type is pressed. NET version is divided into groups that currently support 5 versions of the. NET Framework from. NET 2.0 SP2 to. NET 4.5.1. Each. NET version is also divided into 32-bit and 64-bit groups. The choice of 32-bit or 64-bit is based on the use of the system to determine. For example, when developing a 64-bit system and running on a 32-bit system, you need to use 64-bit System.Data.SQLite.dll at development time, and replace it with 32-bit System.Data.SQLite.dll at release time . (Looks like a very troublesome look ~ ~ See the solution of the latter ~ ~).
3) in each. NET version grouping contains 2 packages, one with the word "bundle" and the other without. The word "bundle" with the words of the dynamic library is compiled in mixed mode, in the use of only need to System.Data.SQLite.dll, and without "bundle" is the unmanaged part and the managed parts are compiled separately, System.Data.SQLite.dll can not be used independently, but also need to have SQLite.Interop.dll to use .
If you want to use the "any CPU" System.Data.SQLite.dll, you must use the word "bundle", which is a binary package that is not a hybrid compilation .
Binary packages that are not hybrid compiled have System.Data.SQLite.dll and SQLite.Interop.dll two dynamic libraries. According to the official instructions, SQLite.Interop.dll can be placed in the same directory as System.Data.SQLite.dll, or can be placed in x86 or x64 sub-directory, by System.Data.SQLite.dll according to the system type call. To confirm, download the following two packages to compare:
Sqlite-netfx40-binary-win32-2010-1.0.90.0.zip
Sqlite-netfx40-binary-x64-2010-1.0.90.0.zip
It turns out that only sqlite.interop.* are different and the other files are exactly the same.
[Comparison result: only sqlite.interop.* different]
The sqlite.interop.* of the two packages are then placed in the x86 and x64 subdirectories and merged into a single package. And then run Test.exe on different types of systems, and the results are completely
The last thing to do is to reference System.Data.SQLite.dll in a Visual Studio project, and then X86\sqlite.interop.dll and x64\ SQLite.Interop.dll Copy to the project root, included in the project, and in the properties, set "copy if newer" or "Copy always". The resulting result is like this:
Testsqlite\bin\debug
│system.data.sqlite.dll
│testsqlite.exe
├─x64
│sqlite.interop.dll
└─x86
SQLite.Interop.dll
After the combination of the package named "Sqlite-netfx40-static-binary-x86-x64-2010-1.0.90.0.zip", shared to everyone, welcome to download the use.
51CTO Resource Station sharing
Cloud disk Sharing
This article from "Border Town Inn," the blog, please be sure to keep this source http://jamesfancy.blog.51cto.com/2516291/1357462
"Turn" about in. Version selection problem using SQLite in NET development