Unable to Load SQLite.Interop.dll Exception RRS feed

  • Question

  • Not sure this is the right forum for this, so please point me elsewhere if not...

    I have a small C# WinForms app developed using Visual Studio Community 2015 on Windows 8.1 on a 64-bit computer and targeting .Net Framework 4.5.2 and Any CPU | Prefer 32-bit. (I also tried targeting just x86). I used NuGet Package Manager to install Entity Framework 6.3.1 and System.Data.SQLite 1.0.101 (which installed System.Data.SQLite, System.Data.SQLite.Core, System.Data.SQLite.EF6, and System.Data.SQLite.Linq), though System.Data.SQLite.Core doesn't show in the project references. I just reinstalled fresh copies as a precaution. The app runs fine in the VS debugger, but the ClickOnce published version triggers an Unable to load SQLite.Interop.dll exception when installed and run on the same computer. I have skeptically tried without success several fixes I found online: (1) installing System.Data.SQLite.Core.MSIL using NuGet; and (2) manually adding some <PropertyGroup> code to the .csproj file, which may have been removed on Build/Publish. I don't see any references to SQLite.Interop.dll in Solution Explorer. There are such dlls in both the x86 and x64 Debug folders of the project, but not in the Release folder which is empty if that matters. All 3 of the SQLite dlls in the project references have Copy Local = true.

    I'm guessing the SQLite NuGet install failed to set some project property/reference, but I don't know what that might be and why.

    Thanks for any help. Steve

    Wednesday, May 4, 2016 12:47 PM


All replies

  • Hi Cincy Steve,

    From the following article, it has a similar issue. please try Magnus's reply.

    1. Try to set the platform target to x86 or x64 (and not Any CPU) before you build.

    2. Project->Properties->Build->Platform target in Visual Studio.

    please put SQLite.Interop.dll where System.Data.SQLite.dll can find it

    Best regards,

    Cole Wu

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Cincy Steve Thursday, May 5, 2016 1:49 PM
    Thursday, May 5, 2016 7:49 AM
  • Cole -

    Thanks for the response.  The suggestion in the link you provided to make sure the dll is in the application directory led me to understand how to fix the problem.  

    The key was to simply add the dll to my VS project as a file (not as a dll reference) and then set its Copy to Output Directory property to Copy if newer.  I'm not clear what's needed if I want to leave the target platform as Any CPU, but for now, I'm up and running. 

    I'm still trying to absorb all this stuff and didn't realize that SQLite.Interop.dll is not managed code and therefore cannot be added as a project reference (I think I now have that right).  It's taken me quite awhile to reach my current understanding of the implications of managed code (MSIL) versus unmanaged code, and I'm sure I still don't get the role of the GAC and the implications of the target platform (Any CPU versus x86 versus x64).  If you happen to know where I might find an explanation of how these things relate, please let me know.

    In any case, you've helped me solve what has been a very frustrating problem.  Thanks again.

    Thursday, May 5, 2016 1:49 PM