Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Using SqliteConnection from an ASP.NET MVC (.NET Framework) application results in a few different exceptions #32614

Copy link
Copy link

Description

@thatnerdyguy
Issue body actions

Example project from following steps below: WebApplication1.zip

  1. (In Visual Studio) Create a new ASP.NET Web Application (.NET Framework), chose MVC
  2. Add a NuGet reference to Microsoft.Data.Sqlite, version 8.0.0
  3. In the HomeController.cs, change the Index() action to:
        public ActionResult Index()
        {
            using (var conn = new SqliteConnection())
            {
                System.Console.WriteLine("SqliteConnection was created!");
            }

            return View();
        }
  1. Run it locally under Debug, and you get something like:
Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
   1) C:\Users\TheUser\AppData\Local\Temp\Temporary ASP.NET Files\vs\68a120e0\7682694\assembly\dl3\8ffaeae5\008bde07_f1d5d901\runtimes\win-x64\native\e_sqlite3.dll
   2) C:\Users\TheUser\AppData\Local\Temp\Temporary ASP.NET Files\vs\68a120e0\7682694\assembly\dl3\8ffaeae5\008bde07_f1d5d901\e_sqlite3.dll
win TryLoad: C:\Users\TheUser\AppData\Local\Temp\Temporary ASP.NET Files\vs\68a120e0\7682694\assembly\dl3\8ffaeae5\008bde07_f1d5d901\runtimes\win-x64\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
  at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
win TryLoad: C:\Users\TheUser\AppData\Local\Temp\Temporary ASP.NET Files\vs\68a120e0\7682694\assembly\dl3\8ffaeae5\008bde07_f1d5d901\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
  at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
NOT FOUND

Now, even if you get around that (we got around it here by doing a runtime copy of e_sqlite.dll to the shadow copy location of SQLitePCLRaw.core.DLL), you can still get exceptions (as of version 8.0.0) from the type initialization of SqliteConnection, which you can approximate (in the attached example project), but uncommenting the ApproximateSqlConnectionStaticCtor() call in HomeController.Index(). In which case, you get:

[ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +96
   System.Type.GetType(String typeName) +62
   WebApplication1.Controllers.HomeController.ApproximateSqlConnectionStaticCtor() in C:\Code\WebApplication1\Controllers\HomeController.cs:50
   WebApplication1.Controllers.HomeController.Index() in C:\Code\WebApplication1\Controllers\HomeController.cs:18
   lambda_method(Closure , ControllerBase , Object[] ) +87
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
   System.Web.Mvc.Async.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +77
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0() +80
   System.Web.Mvc.Async.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +396
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +50
   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +43
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +646
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +182
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134

at

Line 48:                 try
Line 49:                 {
Line 50:                     appDataType = Type.GetType("Windows.Storage.ApplicationData, Windows, ContentType=WindowsRuntime")
Line 51:                         ?? Type.GetType("Windows.Storage.ApplicationData, Microsoft.Windows.SDK.NET");
Line 52: 

Include version information

Microsoft.Data.Sqlite version: 8.0.0
Target framework: net48
Operating system: Windows

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.