gpt4 book ai didi

c# - 带有 "any cpu"编译选项的 SQLite [未选中 "prefer 32 bit"选项时在 64 位机器上崩溃]

转载 作者:IT王子 更新时间:2023-10-29 06:24:17 27 4
gpt4 key购买 nike

我只是按照指示在

SQLite-on-Visual-Studio-with-NuGet-and-Easy-Instructions

我可以用

编译示例 C# 应用程序

"any cpu"

选项。

但是当我运行应用程序时,如果我选择

"prefer 32 bit"

选项,我的应用程序崩溃:

"Unable to load DLL "SQLite.Interop.dll"

如果我取消选中“首选 32 位”选项,它在我的 64 位机器上工作正常。

Why this happen?Any suggestion to fix it?

PS:我使用 64 位 Windows 8。我为 SQLite 提供 [x86] 和 [x64] 文件夹。

附注 1:错误:

System.TypeInitializationException:“System.Data.SQLite.SQLiteFactory”的类型初始值设定项引发异常。 ---> System.DllNotFoundException: 无法加载 DLL 'SQLite.Interop.dll':指定的模块无法找到。 (HRESULT 异常:0x8007007E)在 System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum 操作)在 System.Data.SQLite.SQLite3.StaticIsInitialized()在 System.Data.SQLite.SQLiteLog.Initialize()在 System.Data.SQLite.SQLiteFactory..cctor()--- 内部异常堆栈跟踪结束 ---在 System.Data.SQLite.SQLiteFactory..ctor()

PS 3:

I notice an interesting thing. Although at visual studio it craches, when i run my program exe, by just clicking it, it works.

最佳答案

以管理员身份运行命令提示符。 cd 进入包含 x64 .dll 的目录。然后键入:gacutil -i SQLite.Interop.dll。然后 cd 到包含 x86 .dll 的目录。再次输入:gacutil -i SQLite.Interop.dll。现在它应该可以正常工作了。

这样做是将每个程序集安装到您系统上的 GAC(全局程序集缓存)中。它根据编译方式(x86 或 x64)将它们放入正确的系统缓存目录中。这应该仅用于调试目的。

GAC 32bit vs. 64bit

对于客户端机器。分别为 x86 和 x64 进行部署。当然,请为每个文件添加正确版本的 .dll。

关于c# - 带有 "any cpu"编译选项的 SQLite [未选中 "prefer 32 bit"选项时在 64 位机器上崩溃],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17834041/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com