Using SQLite as a Local Database With .NET MAUI
.NET MAUI can be a bit challenging to use due to its current state of development. It is still really new and often (in my experience) is missing documentation, or sometimes the documentation or related forums posts are outdated. Often when developing mobile apps, the developer needs persistent storage and turns to SQLite to meet those needs. I have attempted using SQLite in one of my first MAUI apps and remember struggling to jump through the right hoops to get my local database set up. I am once again creating a mobile app with MAUI and have stumbled across the same issues.
I began adding my local database by following the .NET MAUI local databases tutorial and pretty much immediately ran into the exception: "could not load file or assembly 'sqlitepclraw.provider.dynamic_cdecl"
System.TypeInitializationException: The type initializer for 'SQLite.SQLiteConnection' threw an exception.
...
System.IO.FileNotFoundException: Could not load file or assembly 'SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b'
I found that I could fix this error by downloading the SQLitePCLRaw.provider.dynamic_cdecl Nuget package. (In Visual Studio, navigate to Tools -> Nuget Package Manager -> Browse -> Search)
Then look for the following:
Comments
Post a Comment