Bug 46361 - System.DllNotFoundException: e_sqlite3 with latest sqlite-net-pcl on Mac with XS Mac. Works on Android & Mac with Jetbrains Rider IDE
Summary: System.DllNotFoundException: e_sqlite3 with latest sqlite-net-pcl on Mac with...
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: MSBuild ()
Version: 2.10.0 (C8)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-03 05:21 UTC by Gary Mc
Modified: 2016-11-03 14:22 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Gary Mc 2016-11-03 05:21:21 UTC
Please try this project https://github.com/buzzware/MacDroidSqlite on Mac Xamarin Studio.

The Android tests pass, the Mac Sqlite one fails with :

	Unhandled Exception:
	System.DllNotFoundException: e_sqlite3
	  at (wrapper managed-to-native) SQLitePCL.SQLite3Provider_e_sqlite3+NativeMethods:sqlite3_libversion_number ()
	  at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number () [0x00000] in <719e69bbbf954c0baf864f57a1e63149>:0 
	  at SQLitePCL.raw.SetProvider (SQLitePCL.ISQLite3Provider imp) [0x00000] in <df26777b0e574c3aa32c47dbac37ac58>:0 
	  at SQLitePCL.Batteries.Init () [0x00005] in <06606d52f10e4114bf994d92eb1573a1>:0 
	  at NUnitLite.Tests.Program.Main (System.String[] args) [0x0001b] in /Users/gary/repos/xamarin/MacDroidSqlite/MacTestRunner/Program.cs:20 

Xamarin Studio Community
Version 6.1.2 (build 44)
Installation UUID: 972e9eda-ec73-464e-a091-f2ea7102a1dd
Runtime:
	Mono 4.6.2 (mono-4.6.0-branch/db69866) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406020006

NuGet
Version: 3.4.3.0

Xamarin.Profiler
Not Installed

Xamarin.Android
Version: 7.0.2.37 (Xamarin Studio Community)
Android SDK: /Users/gary/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
		7.0   (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 24

Java SDK: /usr
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin Android Player
Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

Apple Developer Tools
Xcode 8.0 (11246)
Build 8A218a

Xamarin.iOS
Version: 10.2.1.4 (Xamarin Studio Community)
Hash: 316e533
Branch: xcode8.1
Build date: 2016-10-31 18:05:23-0400

Xamarin.Mac
Version: 2.10.0.111 (Xamarin Studio Community)

Xamarin Inspector
Version: 0.9.0.14
Hash: 4d868da
Branch: master
Build date: Mon Jun 13 19:14:13 UTC 2016

Build Information
Release ID: 601020044
Git revision: 0ccfcd52b95305ebd5b7eca0d88c1017035910ae
Build date: 2016-10-28 15:12:43-04
Xamarin addins: a39a869d8a78d87bdc6775f696c13a4cc9024501
Build lane: monodevelop-lion-cycle8

Operating System
Mac OS X 10.11.6
Darwin Garys-MBP.gateway 15.6.0 Darwin Kernel Version 15.6.0
    Mon Aug 29 20:21:34 PDT 2016
    root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64

Enabled user installed addins
Gorilla Player 0.9.1.2
Xamarin Inspector 0.9.0.14
Comment 1 Chris Hamons 2016-11-03 14:22:23 UTC
It appears that libe_sqlite3.dylib is not being property copied into your Xamarin.Mac bundle. 

SQLitePCLRaw.lib.e_sqlite3.osx.targets does not appear to have Xamarin.Mac unified support. 

It should likely use the msbuild entry point shown here:

https://developer.xamarin.com/samples/mac/UseMSBuildToCopyFilesToBundleExample/

to copy content into the bundle. 

Work Around:

1) Use https://developer.xamarin.com/samples/mac/UseMSBuildToCopyFilesToBundleExample/ and create a step to copy libe_sqlite3.dylib from your bin dir to the MacTestRunner.app/Contents/MonoBundle folder
2) Or add a native reference to MacDroidSqlite/packages/SQLitePCLRaw.lib.e_sqlite3.osx.1.1.0/runtimes/osx-x64/native/libe_sqlite3.dylib so mmp handles things for you.

In any case, getting libe_sqlite3.dylib in your bundle will fix things.
Comment 2 Chris Hamons 2016-11-03 14:22:56 UTC
Thanks for the detailed example by the way!

It made diagnosing this problem significantly easier.