-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed as duplicate
Closed as duplicate
Copy link
Description
Running an application with Sqlite DB connection throws the following exception:
System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Important! it DOES work properly for target framework net6.0-windows, and it DOES NOT work for target framework net48
Code
I don't know if it can be helpful
public SQLiteDatabase()
{
Connection = new SQLiteConnection();
}Stack traces
(the part which relates to Microsoft.Data.Sqlite)
System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Data.Sqlite.Utilities.ApplicationDataHelper.GetFolderPath(String propertyName)
at Microsoft.Data.Sqlite.Utilities.ApplicationDataHelper.get_LocalFolderPath()
at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
at Microsoft.Data.Sqlite.SqliteConnection..cctor()
--- End of inner exception stack trace ---
at Microsoft.Data.Sqlite.SqliteConnection..ctor()
Version information
Microsoft.Data.Sqlite version: 6.0.0
Target framework: net48
Operating system: Windows 10