Problem:
I'm trying to develop an ASP.NET MVC (.Net Framework 4.7.2) web app in which I want to use Microsoft.Data.Sqlite version (5.0.2), but when I run it my web app crashes (both in debug IIS Express, and in app.publish on local IIS on Windows 10) at following code line:
SqliteConnection dbConn = new SqliteConnection("Data Source=test.db");
The exception thrown is as under:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
Source=Microsoft.Data.Sqlite
StackTrace:
at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)
at sqliteTest.Controllers.ValuesController.Get() in C:\Users\FaqeerHussain\source\repos\sqliteTest\sqliteTest\Controllers\ValuesController.cs:line 16
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception 2:
Exception: Library e_sqlite3 not found
What I've tried so far:
Following Inner Exception: Library e_sqlite3 not found tried looking around the 'bin' folder, and found that e_sqlite3.dll is already there in bin\runtimes\win-x64\native and also in bin\runtimes\win-x86\native folders, both contain e_sqlite3.dll.
Tried copying manually the above-mentioned x86/x64 e_sqlite3.dll to root bin folder but the error still remains.
What should I do to get Microsoft.Data.Sqlite working in my ASP.NET MVC (.NET Framework 4.7.2) web app?
