SQLite. NET application Adaptive 32-bit/64-bit System Z

Source: Internet
Author: User
Tags sqlite database sqlite download vc runtime visual studio 2010

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 that's not important, it's important that System.Data.SQLite is made up of two parts of code, some unmanaged C + + code implementations, and part of the managed code with the. 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", which has a clear boldface description in the description of the download package.


[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

SQLite. NET application Adaptive 32-bit/64-bit System Z

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.