gpt4 book ai didi

SQLite 无法从 F# FSI 执行

转载 作者:行者123 更新时间:2023-12-03 15:56:24 25 4
gpt4 key购买 nike

没有任何 SQLite .NET 包在 FSI 中工作,即使在 fs 项目中引用模块时也是如此。我试过 System.Data.SQLite,SQLitePCL.raw , 和 Microsoft.Data.Sqlite .

来自 System.Data.SQLite docs :

If the executable that starts the process consists entirely of managed code, it will run with the native processor architecture of the machine, which will be x64 on an x64 machine. Later on, this will cause assemblies containing any native code compiled for x86 (e.g. the "System.Data.SQLite.dll" mixed-mode assembly, the "SQLite.Interop.dll" native interop assembly, or the "sqlite3.dll" native library) to fail to load, typically resulting in a BadImageFormatException being thrown.

抛出的错误通常看起来像

System.DllNotFoundException: Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_open_v2(IntPtr filename, Sqlite3Handle& ppDb, Int32 flags, IntPtr vfs)
at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_open_v2(String filename, Sqlite3Handle& ppDb, Int32 flags, String vfs)
at Microsoft.Data.Sqlite.SqliteConnection.Open()
at <StartupCode$FSI_0009>.$FSI_0009.main@() in E:\BitSync\NonGitProjects\SQLiteSandbox\Microsoft.DataSandbox\Scripts\Script1.fsx:line 7

Demo gist

有人找到解决办法了吗? SQLite 在编译的 F# 程序和 Debug模式下工作得很好。

最佳答案

文章Loading Native DLLs in F# Interactive具有解决加载 native DLLS 问题的正确技术。

以我为例,我成功尝试了

System.Environment.CurrentDirectory <- @"D:\Projects\SQLiteSandbox\SQLiteSandbox\bin\Debug\x86"

关于SQLite 无法从 F# FSI 执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35707448/

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