在 32 位和 64 位 C# 世界中使用 System.Data.SQLite 的选项 [英] Options for using System.Data.SQLite in a 32bit and 64bit C# world

查看:34
本文介绍了在 32 位和 64 位 C# 世界中使用 System.Data.SQLite 的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解为什么在 32 位和 64 位版本中提供 System.Data.SQLite.dll.所以让我们不要纠结于此,继续前进.:)

I understand WHY the System.Data.SQLite.dll is provided in 32 bit and 64 bit builds. So lets not dwell on that and move on. :)

既然是这样完成的,它似乎使纯 C# 开发变得更加困难,有 3 个选择.

Since it is done this way it seems to make pure C# development a tad more difficult with 3 choices to make.

  1. 是仅支持 32 位并强制管理程序集编译 x86 并在 32 或 64 位运行时处理它位,从而失去了使用 64 位时的优势环境.

  1. Is to support only 32-bit and force there managed assembly to compile x86 and deal with that in running in 32 or 64 bit, and there by lose advantages of when you are on a 64 bit environment.

是强制64位,只支持64位,丢了能够在 32 位上运行但获得 64 位的所有优点.

Is to force 64 bit and only support 64 bit and losing the ability to run on 32 bit but gaining all the advantages of 64 bit.

是创建其程序集的两个版本,一个是编译 x86 并使用 32 位 SQLite 和另一个编译 x64并使用 64 位 SQLite.它防止使用ANY"作为编译选项并且能够轻松地将单个构建部署到任一类型.它的从开发的角度来看,管理起来并不像我们那么可怕需要两个项目.只有正式的 C# 代码合二为一,而另一个只会使用链接"到另一个中的代码.这个仅用于编译目的.仍然让我们不得不管理用于部署的两个输出.

Is to create two versions of their assembly one that compiles x86 and uses 32 bit SQLite and another that compiles x64 and uses 64bit SQLite. It prevents using "ANY" as a compile option and being able to easily deploy a single build to either type. Its not so horrible to manage from a development point of view as we will need two projects. Only having the C# code officially in one, and the other will just use "links" to the code in the other. This is for compiling purposes only. Still leaves us with having to manage two outputs to for deployments.

说了这么多,我只是想确认以上是唯一正确的选择.

With all that said I am only looking for confirmation that the above are the only correct choices.

但是,如果我忽略了其他选择,请告诉我.具体来说,如果有办法获得一个可以编译为 ANY 的单个 C# DLL,那么它可以利用 32 位或 64 位,具体取决于它的运行位置并仍然使用 System.Data.SQLite.dll.

If however there are other choices that I am overlooking please let me know. Specifically if there is way to get a single C# DLL that can compile to ANY so it can take advantage of 32 or 64 bit depending on where its run and still use System.Data.SQLite.dll.

推荐答案

有两种常见的解决方案可以让您的主应用程序保持在 AnyCPU 上:

There are 2 common solutions for keeping your main application at AnyCPU:

  • 将 x86 和 x64 程序集安装到 GAC:它们可以(应该!)具有相同的程序集名称,并且 GAC 将自动决定是使用 x86 还是 x64 版本.

  • Install both the x86 and the x64 assemblies into the GAC: They can (should!) have identical assembly names and the GAC will automatically decide whether to use x86 or x64 version.

连接到 AppDomain.AssemblyResolve 并使用 Assembly.LoadFrom

这篇关于在 32 位和 64 位 C# 世界中使用 System.Data.SQLite 的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆