x86 DLL Works But Not x64 DLL

淺唱寂寞╮ 提交于 2019-12-07 03:31:29

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.

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.

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.

For such cases, there's no better technology than Nuget ! You can use directly the SqlLite nuget package, which is explicitly compatible for x86/x64. I tried it in AnyCpu, x86 and x64, and I have no compilation error at all in both cases.

So you just have to remove your old references, and right-click on the project references, and choose "Manage NuGet Packages", then search for System.Data.SQLite.

And moreover, you will be forever up-to-date :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!