2016-02-29 71 views
3

即使引用fs项目中的模块,SQLite .NET包也不会在FSI中工作。我试过System.Data.SQLite,SQLitePCL.rawMicrosoft.Data.SqliteSQLite无法从F#执行FSI

System.Data.SQLite docs

如果启动的过程中可执行完全的托管代码组成,它会随着机器的本机处理器架构,这将是在x64机器在x64运行。稍后,这将导致包含为x86编译的任何本地代码的程序集(例如“System.Data.SQLite.dll”混合模式程序集,“SQLite.Interop.dll”本机互操作程序集或“sqlite3.dll”本机库)无法加载,通常会导致引发BadImageFormatException。

的错误通常抛出貌似

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>[email protected]() in E:\BitSync\NonGitProjects\SQLiteSandbox\Microsoft.DataSandbox\Scripts\Script1.fsx:line 7 

Demo gist

有没有人找到了解决这个? SQLite在编译的F#程序和调试模式下工作得很好。

+1

32位或64位的FSI? –

+2

不知道你是否试过这个,或者它是否会帮助,但不能伤害提及它。请参阅:[在F#Interactive中加载原生DLL](http://christoph.ruegg.name/blog/loading-native-dlls-in-fsharp-interactive.html) –

+0

@GuyCoder这正是帮助我使它工作一些几周前。 – TeaDrivenDev

回答

3

artice Loading Native DLLs in F# Interactive有正确的技术来解决加载原生DLLS的问题。

在我的情况在我的情况下,我成功尝试

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