作者:问道摩托 | 来源:互联网 | 2023-05-20 13:04
我正在尝试包含System.Data.SQLite
我的项目,该项目使用C#编码并使用.NET Framework v4.我有点困惑......我正在运行Windows 8.1 x64,项目的平台目标设置为Any CPU
.如果我包含x64版本,System.Data.SQLite.dll
那么我会收到错误消息The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
.但是,如果我包含其x86
版本,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).
1> Rob Caplan -..:
除非您需要x64版本,否则只需包含x86版本并将项目构建为x86.除非您需要64位地址空间,否则这对大多数项目都是安全的.
只有当您的应用程序是纯粹管理且对特定体系结构没有任何依赖性时,才应使用AnyCPU.使用SQLite等本机代码时,应用程序应始终设置特定的平台目标.
xite版本的SQLite而不是x64的原因是在Visual Studio的现代版本中,AnyCPU配置默认为/ platform:anycpu32bitpreferred而不是/ platform:anycpu.使用anycpu32bitpreferred时,应用程序将尽可能使用32位模式,并且仅在32位模式不可用时才使用64位模式.