86 DLL的作品,但不是64位的DLL不是、作品、DLL

由网友(痞子绅士)分享简介:我想包括 System.Data.SQLite 与我的项目是codeD在C#和使用的.NET Framework 4版。我有点糊涂了......我运行Windows 8.1 x64和目标平台为项目设置为任何CPU 。如果我有 System.Data.SQLite.dll 的x64版本的话,我得到一个错误说的类型或命名空...

我想包括 System.Data.SQLite 与我的项目是codeD在C#和使用的.NET Framework 4版。我有点糊涂了......我运行Windows 8.1 x64和目标平台为项目设置为任何CPU 。如果我有 System.Data.SQLite.dll 的x64版本的话,我得到一个错误说的类型或命名空间名称SQLite的'不存在在命名空间System.Data这'(是否缺少程序集引用?)。不过,如果我包括 86 版本 System.Data.SQLite.dll 那么它编译罚款。难道不应该是周围的其他方式(不应该在x86版本无法编译)?由于x86版本的作品,那么我可以只包括x86版本的编译后的项目?如果我需要既包括x86和x64版本 System.Data.SQLite.dll (以及 SQLite.Interop.dll ),那么怎么可能我去这样做?我还应该注意到 System.Data.SQLite 的版本是v1.0.94.0(并且是.NET Framework 4的)。

I'm trying to include System.Data.SQLite with my project which is coded in C# and uses .NET Framework v4. I'm a little confused... I'm running Windows 8.1 x64 and the platform target for the project is set to Any CPU. If I include the x64 version of System.Data.SQLite.dll then I get an error saying The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?). However, if I include the x86 version of System.Data.SQLite.dll then it compiles fine. Shouldn't it be the other way around (shouldn't the x86 version not compile)? Since the x86 version works, then can I include just the x86 version with the compiled project? If I need to include both the x86 and x64 version of System.Data.SQLite.dll (as well as SQLite.Interop.dll) then how might I go about doing that? I should also note the version of System.Data.SQLite is v1.0.94.0 (and is for .NET Framework 4).

推荐答案

除非你需要的64位版本,你可以只包含x86版本和建设项目为86。这是安全的大多数项目,除非你需要的64位地址空间。

Unless you need the x64 version you can include just the x86 version and build your project as x86. This is safe for most projects, unless you need the 64-bit address space.

您应该使用值为anycpu只有当你的应用程序是纯粹的管理,不会对某一种硬件架构任何依赖。当使用本机code,如SQLite的应用程序应始终将特定平台的目标。

You should use AnyCPU only when your app is purely managed and doesn't have any dependencies on a specific architecture. When using native code such as SQLite the app should always set the specific platform target.

SQLite的x86版本的作品,而不是64位的原因是,在现代版本的Visual Studio的值为anycpu配置默认为/平台:anycpu32bit preferred而非/平台:值为anycpu。随着anycpu32bit preferred应用程序将使用32位模式,如果可能的话,将使用64位模式下只有32位模式下无法使用。

The reason the x86 version of SQLite works rather than the x64 is that in modern versions of Visual Studio the AnyCPU configuration defaults to /platform:anycpu32bitpreferred rather than to /platform:anycpu. With anycpu32bitpreferred the app will use 32-bit mode if possible and will use 64-bit mode only if 32-bit mode is not available.

阅读全文

相关推荐

最新文章