【发布时间】:2021-04-21 08:02:52
【问题描述】:
问题:
我正在尝试开发一个 ASP.NET MVC (.Net Framework 4.7.2) Web 应用程序,我想在其中使用 Microsoft.Data.Sqlite 版本 (5.0.2) ,但是当我运行它时,我的 Web 应用程序在以下代码行崩溃(在调试 IIS Express 和 Windows 10 上本地 IIS 上的 app.publish 中):
SqliteConnection dbConn = new SqliteConnection("Data Source=test.db");
抛出的异常如下:
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
到目前为止我所做的尝试:
跟随Inner Exception: Library e_sqlite3 not found 尝试查看'bin' 文件夹,发现e_sqlite3.dll 已经存在于bin\runtimes\win-x64\native 和bin\runtimes\win-x86\native 文件夹中,两者都包含e_sqlite3.dll。
尝试手动将上述 x86/x64 e_sqlite3.dll 复制到根bin 文件夹,但错误仍然存在。
我应该怎么做才能让Microsoft.Data.Sqlite 在我的 ASP.NET MVC (.NET Framework 4.7.2) Web 应用程序中工作?
【问题讨论】:
标签: c# asp.net .net sqlite iis