Chase Florell
Chase Florell

Reputation: 47427

Unable to load DLL 'sqlite3': The specified module could not be found

I'm having a heck of a time getting my tests to run against my SQLite Data Provider.

I've looked at the suggested links here on stackoverflow, but none of them seem to get me going down the right path.

I've downloaded the Windows Precompiled Binaries for sqlite3.dll

I've copied the sqlite3.dll into both my Sqlite\bin directory as well as my Tests\bin directory dll copied into bin directories

Unfortunately when I run my tests, I get the following error

failed test

Is there a clear cut way to get this working both in my Windows dev environment (primary goal right now) as well as running in Android and IOS (required in the near future)?

Also, if it matters, here are my Sqlite project references.

enter image description here

Upvotes: 3

Views: 19629

Answers (4)

Poulad
Poulad

Reputation: 1321

I am using VS2017 and solved the issue by adding the following task to copy the assembly.

<Target Name="Ensure SQLite assemblies copied" AfterTargets="Build" Condition=" '$(Platform)' == 'x64' ">
  <Copy SourceFiles="$(OutDir)x64\SQLite.Interop.dll" DestinationFolder="$(OutDir)" />
</Target>

Upvotes: 0

SurenSaluka
SurenSaluka

Reputation: 1591

When I add the following libraries the error went away

  1. Microsoft Visual C++ Runtime Package (V11.0)
  2. SQLite for Windows Runtime (V3.8.7.1)

When I add the following libraries the error went away

Upvotes: 3

Chase Florell
Chase Florell

Reputation: 47427

So the answer for me was quite simple. I wired up a Pre-Build event that checks the architecture of the machine, and copies the appropriate dll into the output bin directory.

Now anyone on our team can simply run REBUILD, and the proper dll will be available to run against SQLite.

if '$(PROCESSOR_ARCHITECTURE)'=='AMD64' (xcopy /y "$(ProjectDir)x64\sqlite3.dll" ".\") 
if '$(PROCESSOR_ARCHITECTURE)'=='x86' (xcopy /y "$(ProjectDir)x86\sqlite3.dll" ".\")
if '$(PROCESSOR_ARCHITEW6432)'=='AMD64' (xcopy /y "$(ProjectDir)x64\sqlite3.dll" ".\")

Upvotes: 5

Noctis
Noctis

Reputation: 11783

Can't put this in comments, so here's what I got: enter image description here

Also, have a look at Similar problem.

Last, but not least, did you try to add a reference to the SQLite.Inetrop.dll (in the references)? References -> add -> just browse to where your SQLite is, select view all, and add a reference to the Interop.dll as well)

Upvotes: 0

Related Questions