Open MSicc opened 2 years ago
hmmmmmmmm @praeclarum any thoughts on this? this is all I am doing: https://github.com/jamesmontemagno/monkey-cache/blob/master/src/MonkeyCache.SQLite/Barrel.cs#L48
Are you debugging it locally on your machine? you may need to give your app disk access perhaps, it would probably be different in release. I will test out though.
Are you debugging it locally on your machine? you may need to give your app disk access perhaps, it would probably be different in release. I will test out though.
I am debugging it locally, yes.
I am using the Xamarin.Essentials.FileSystem API to get the AppDataDirectory for my cache both on iOS and MacOS. I also use the same Bundle Identifier on both platform (which shouldn't cause a problem, right?).
I haven't activated the sandbox for my app yet because I am only in the beginning of my Mac application journey...
It is also reproducable - here is a minimum sample .
I just created a new XF app with just iOS. Then added the MacOS project and followed the docs
Then I added the MonkeyCache SQLite package and finally, doing the same I am doing in my original app.
Hope this helps to find the problem.
awesome! thanks for the repro, i will take a look
I just forked your repo and added a MacOS test project to investigate the issue further. With this, I was able to extract the full stack trace for the error:
System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception. ---> System.DllNotFoundException: e_sqlite3 assembly:<unknown assembly> type:<unknown type> member:(null) 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 <0c6005d444974cd28bc8604fad3b12d6>:0 at SQLitePCL.raw.SetProvider (SQLitePCL.ISQLite3Provider imp) [0x00008] in <5c1b545cd56d4bbda42fb802eb1e354a>:0 at SQLitePCL.Batteries_V2.Init () [0x00005] in <f6de2824d7db436499a4a67aca6b7fab>:0 at SQLite.SQLiteConnection..cctor () [0x00016] in <01c96d411fe34bd5940c99a56515582b>:0 --- End of inner exception stack trace --- at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr) at MonkeyCache.SQLite.Barrel..ctor (System.String cacheDirectory) [0x0004b] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.SQLite/Barrel.cs:48 at MonkeyCache.SQLite.Barrel.get_Current () [0x00000] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.SQLite/Barrel.cs:33 at MonkeyCache.TestApp.MainPage..ctor () [0x00078] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp/MainPage.xaml.cs:32 at MonkeyCache.TestApp.App..ctor () [0x0000f] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp/App.xaml.cs:16 at MonkeyCache.TestApp.MacOS.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00007] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp.MacOS/AppDelegate.cs:34 at (wrapper managed-to-native) AppKit.NSApplication.NSApplicationMain(int,string[]) at AppKit.NSApplication.Main (System.String[] args) [0x00040] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/AppKit/NSApplication.cs:116 at MonkeyCache.TestApp.MacOS.MainClass.Main (System.String[] args) [0x00017] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp.MacOS/Main.cs:11 [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception. ---> System.DllNotFoundException: e_sqlite3 assembly:<unknown assembly> type:<unknown type> member:(null) 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 <0c6005d444974cd28bc8604fad3b12d6>:0 at SQLitePCL.raw.SetProvider (SQLitePCL.ISQLite3Provider imp) [0x00008] in <5c1b545cd56d4bbda42fb802eb1e354a>:0 at SQLitePCL.Batteries_V2.Init () [0x00005] in <f6de2824d7db436499a4a67aca6b7fab>:0 at SQLite.SQLiteConnection..cctor () [0x00016] in <01c96d411fe34bd5940c99a56515582b>:0 --- End of inner exception stack trace --- at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr) at MonkeyCache.SQLite.Barrel..ctor (System.String cacheDirectory) [0x0004b] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.SQLite/Barrel.cs:48 at MonkeyCache.SQLite.Barrel.get_Current () [0x00000] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.SQLite/Barrel.cs:33 at MonkeyCache.TestApp.MainPage..ctor () [0x00078] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp/MainPage.xaml.cs:32 at MonkeyCache.TestApp.App..ctor () [0x0000f] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp/App.xaml.cs:16 at MonkeyCache.TestApp.MacOS.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00007] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp.MacOS/AppDelegate.cs:34 at (wrapper managed-to-native) AppKit.NSApplication.NSApplicationMain(int,string[]) at AppKit.NSApplication.Main (System.String[] args) [0x00040] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/AppKit/NSApplication.cs:116 at MonkeyCache.TestApp.MacOS.MainClass.Main (System.String[] args) [0x00017] in /Users/msiccdev/Git/monkey-cache/src/MonkeyCache.TestApp.MacOS/Main.cs:11
Searching for the error message leads me to several Mac specific issues in the sqlite.net repo
Even if it doesn't feel right, following this recommendation leads to the test app at least starting up. (Haven't followed the road further until now, just leaving this crumbs here).
Hope this helps in the meantime.
Odd as I know for sure frank uses sqlite-net in his mac apps....
Got it so it seems like you had to manually add that reference hmmmmm
You both are talking about sqlite-net often enough ;-)
If it was my lib, I would just include in the project file as Mac specific package. Just to save others some time. On the other hand, I am not sure how this turns out on MAUI, which has its own challenges (at least for now).
The problem is still present with .NET MAUI... Had to follow this recommendation to get it working with MacCatalyst...
As I was able to use the SQLite provider with the main library in my Xamarin.Forms iOS app, I tried to use it in the additional Mac app as well.
It creates the MonkeyCache folder in the folder I specify, but does not create the db file(s). I tried several folders on my Mac without success.
If I try to access Barrel.Current, I get this:
System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception.
I am running out of ideas why this is happening with the latest version of the package and MacOS Monterey.
Any hint how to get around this would me helpful.