Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite with VS2012 and .NET 4.5 -- ANY CPU Build

I've tried looking through the answers for related questions, but haven't found anything that isn't a few years old (unsure if they are still the go-to answer) or that answers my question fully.

Requirements:

  • I'm developing a C# application that is to run on BOTH 32-bit and 64-bit computers. My client does NOT want to create two different releases based on x86 vs x64.
  • We're using SQLite, VS2012, and .NET 4.5. Here are the available DLLs for SQLite: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

Unfortunately, the DLLs are split into 32-bit or 64-bit releases.

Questions:

  • Is it possible to include both DLLs and switch over them based on processor? How do I do this?
  • I've read a bit about the GAC, and from what I've read, it's a local solution. To implement this for my application I'd have to install the DLLs to the GAC for every installation, correct?
  • Can I force the program to run in 32-bit mode in a 64-bit environment, thus losing the 64-bit advantages but being able to run my program in both environments without issue?

Some possible answers that I'm unsure would work for my situation:

  • See most recent answer (third one down): 64-bit SQLite.dll and Any CPU
  • The answer from 2012 seemed promising, but the first comment on that answer dashed my hopes: Options for using System.Data.SQLite in a 32bit and 64bit C# world
like image 293
CODe Avatar asked Oct 27 '13 21:10

CODe


People also ask

What is the x86 version of SQLite?

This binary package contains all the binaries for the x86 version of the System.Data.SQLite 1.0.115.5 (pre-3.37.0) package. The Visual C++ 2010 SP1 runtime for x86 is statically linked.

What version of SQLite do I need for NuGet?

This NuGet package contains all the binaries for both the x86 and x64 versions of System.Data.SQLite 1.0.115.5 (pre-3.37.0), except those needed to support LINQ and Entity Framework 6. The .NET Framework 3.5 SP1, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, or 4.7.2 is required.

What is included in the SQLite x64 package?

This binary package contains all the binaries for the x64 version of the System.Data.SQLite 1.0.115.5 (pre-3.37.0) package. The Visual C++ 2005 SP1 runtime for x64 and the .NET Framework 2.0 SP2 are required.

Is there a database core package for SQLite?

This is a legacy package; if possible, please use either the "System.Data.SQLite" or "System.Data.SQLite.Core" package instead.


1 Answers

Yes. Just use the NuGet package System.Data.SQLite. It will install an x86 and x64 subdirectory into your project and, when compiled, into your bin. The 32 bit and 64 bit interop DLLs are copied into those and selected appropriately at runtime based on your CPU. So you build with "Any CPU" selected and can run your application on 32 or 64 bit Windows.

like image 64
Tyler Jensen Avatar answered Sep 17 '22 14:09

Tyler Jensen