0

I am starting to try and figure out some SQLite and I tried to set up a Unit Test project - but I can't seem to get it to run. I have used NuGet to grab the following:

  • SQLite.Net PCL
  • sqlite-net
  • System.Data.SQLite

Everything compile fine, but when I try to run anything as simple as initialization code, I get:

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

Now I know that means the reference cannot be found - am I missing something here? Thank you.

naspinski
  • 34,020
  • 36
  • 111
  • 167
  • @Grant H, - can you tell me how I do that? Or point me to an example? I am new at this (Android/Xamarin) – naspinski Aug 20 '14 at 05:38
  • Did you add the Nuget package to your test project? The native Sqlite library is added as binary content, not a .NET reference. The package executes a script to add the proper native dlls to platform-specific folders. – Panagiotis Kanavos Aug 20 '14 at 13:01
  • 1
    You either can write post-build copy as mentioned in the duplicate question's accepted answer, or use the **DeploymentItemAttribute**: http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.deploymentitemattribute.aspx – Will Marcouiller Aug 20 '14 at 13:03

1 Answers1

1

sqlite3 is an external, non CLR dll that's required. My guess is you're referencing your project from the unit test library, but not copying the unmanaged dll to the unit test's directory (or even in your main project, depending on the package used, I don't know if they actually include the dll).

Here's a SO question that deals with a similar issue. Since you're deploying to Android, and developing in Windows(?), you'll need a different version for your unit test than the version that's deployed with your Android Application.

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

If you look at the information in the referenced SO answer, you can see that they've copied the sqlite3.dll files to the respective bin directories so the managed wrapper sees and calls it when needed.

Community
  • 1
  • 1
Grant H.
  • 3,689
  • 2
  • 35
  • 53