在将 vs2015 .net standard 升级到 vs2017 时,我在测试项目中遇到以下错误。
Unable to load DLL ‘sqlite3’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
它适用于 vs2015,sqlite 提供程序 1.0.101.0
新环境:Visual Studio 2017,TargetFramework="net461"使用 .netcore1.1 包,sqlite 提供程序 1.0.105.0
我已经尝试了所有可以从互联网上获得的解决方案,如下所示,但都是徒劳的。我试过了,
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType><AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> 已安装的提供程序:sqlite-netFx46-static-binary-bundle-Win32-2015-1.0.105.0.zip 来自 http://system.data.sqlite.org
已安装 System.Data.SQLite 1.0.105 nuget 包
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_sqlite3.sqlite3_open_v2(IntPtr filename, Sqlite3Handle& ppDb, Int32 flags, IntPtr vfs)
at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_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 Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open()
at Microsoft.EntityFrameworkCore.Storage.Internal.SqliteRelationalConnection.Open()
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer)
at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](Func`2 operation, Func`2 verifySucceeded, TState state)
at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, Func`2 operation, TState state)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()
at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_Include>d__30`1.MoveNext()
at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_Include>d__30`1.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__15`2.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at
一切都无济于事。 我错过了什么吗?
最佳答案
通过绕行解决。
我在 visual studio 2017 中尝试了 POC,有一个 net461 项目和一个单元测试项目,net461 项目与 sqlite 配合得很好,但单元测试项目需要引用 sqlite package ,
然而,sqlite 包不能很好地与 net461 类库项目一起使用,没有 dll 被提取到 bin/x86 或 bin/x64 文件夹
解决方法是将 x86/sqlite3.dll、x64/sqlite3.dll 添加到项目中作为“内容”和“复制更新”(否则,它可能会被使用,并导致错误),如下所示
System.Data.SQLite,这里并不是真正需要的。
现在可以了。希望sqlite包能尽快兼容visual studio 2017
关于sqlite - Visual Studio 2017 更新问题 : Unable to load DLL ‘sqlite3’ : The specified module could not be found.(HRESULT 异常:0x8007007E),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43393332/