Visual Studio 2017 update issue: Unable to load DLL ‘sqlite3’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

5

While upgrading vs2015 .net standard to vs2017, I got the following error in test project.

Unable to load DLL ‘sqlite3’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

It works well with vs2015, sqlite provider 1.0.101.0

New Environment: Visual Studio 2017, TargetFramework="net461" using .netcore1.1 packages, sqlite provider 1.0.105.0

I have tried all resolutions I can get from internet as following, but all in vain. I've tried,

  1. Added below lines to .csproj, <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType><AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  2. Selected testing processor as x86
  3. Installed provider: sqlite-netFx46-static-binary-bundle-Win32-2015-1.0.105.0.zip from http://system.data.sqlite.org

  4. Installed System.Data.SQLite 1.0.105 nuget package

  5. Tried put sqlite3.dll (x86) to project folder, set it as "Content" and "copy always", even tried copying the file to bin/x86/, it complains a new error

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 
  1. Downloaded C++ Runtime for 2017
  2. Installed extension of "SQLite runtime for windows"

All doesn't help. Anything I missed?

sqlite3
visual-studio-2017
asked on Stack Overflow Apr 13, 2017 by Elaine • edited May 4, 2017 by Daniel A. White

1 Answer

4

Solved by a walk-around.

I tried POC in visual studio 2017, with a net461 project and a unit testing project, net461 project works well with sqlite, yet unit testing project needs referencing sqlite package, enter image description here

Yet, the sqlite package doesn't work well with net461 class library project, no dll is extacted to bin/x86 or bin/x64 folder

enter image description here

The walk-around is adding x86/sqlite3.dll, x64/sqlite3.dll to project as "Content" and "Copy it Newer" (otherwise, it could be being used, and cause error) as below enter image description here enter image description here

System.Data.SQLite, is not really needed here.

Now it works. Hope sqlite package will be compatible soon with visual studio 2017

answered on Stack Overflow Apr 14, 2017 by Elaine • edited Apr 14, 2017 by Elaine

User contributions licensed under CC BY-SA 3.0