Keep getting "Unable to load DLL 'SQLite.Interop.dll':" in VS 2017 with C# .net 4.6.1

1

I am getting the following error in my Web project in Visual Studio 2017:

Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Now, I have read ALL of the other StackOverflow questions with the same or similar titles and NONE of the mentioned solutions have worked for me.

The strangest thing is that the SQLite.Interop.dll file is inside my \bin folder and inside both x86 and x64.

Fusion log is enabled but it doesn't seem to pick this up at all.

It "feels" to me like something is being cached by my IIS.

Here is some more detail about my environment and what I'm doing:

  • I am using IIS 10.0.17134.1
  • Running on Windows 10 build 17134.523
  • Using Visual Studio 2017 (15.8.6)
  • .Net project configured to use .Net 4.6.1
  • The culprit call is to NHibernate (5.2.3)

    Configuration.BuildSessionFactory()

  • My project uses FluentNhibernate and many other nuget packages.
  • I'm only using the Sqlite Nuget package System.Data.SQLite.Core version 1.0.109.2

Further, I've got a base project where this actually works.

I am converting this to a Visual Studio template, exporting it and then I create a new project of my custom visual studio template type.

It is this newly created project that does not want to work. In fact, when i run the first time, visual studio downloads all the nuget packages but does not copy the sqlite.interop.dll files over.

Only when I re-build the solution a second time, does it copy the files over.

But I still get the error.

So I want to emphasize, the actual dll's (SQLite.Interop.dll) do exist in the bin directory, and the IIS website is hosted in that directory.

But I still get this error.

Is there any reason why this is happening??

I have a feeling it might be related to the Visual Studio template, but i can't see any difference with my manually created project and the template created one. But I would think this is sort of besides the point, why am I getting the error?

Any help is appreciated.

c#
.net
nhibernate
visual-studio-2017
sqlite-net
asked on Stack Overflow Jan 28, 2019 by Quintonn

1 Answer

0

I also had this error for a while while trying to work in an Entity Framework designer edmx file.

I finally found the solution from the SQLite FAQ https://system.data.sqlite.org/index.html/doc/trunk/www/faq.wiki#q10

(11) Why do I get a DllNotFoundException (for "sqlite3.dll" or "SQLite.Interop.dll") when trying to run my application?

Either the named dynamic link library (DLL) cannot be located or it cannot be loaded due to missing dependencies. Make sure the named dynamic link library is located in the application directory or a directory along the system PATH and try again. Also, be sure the necessary Visual C++ runtime redistributable has been installed unless you are using a dynamic link library that was built statically linked to it.

So I simply copied the SQLite.Interop.dll to somewhere referenced by the PATH variable (I was lazy so I simply dropped it in C:\Windows). I did not had to manually select x86 or x64 for my project, it still uses Any CPU and now everything works.

answered on Stack Overflow Apr 28, 2019 by jBelanger

User contributions licensed under CC BY-SA 3.0