1
votes

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.

1
Did you check the build platform (x86, x64) ? You can check the target of the SQLLite DLL and the build target of your application. Check if both match. - Manoj Choudhari
Have you checked this answer? stackoverflow.com/a/32639631/259946 - hazzik
Yes, the dll is the correct target type and yes I did look at that stackoverflow question and i've tried all those steps. @hazzik, those steps are just to get the dll's to copy to output location, and like i mention, that is happening. - Quintonn
It's hard to verify whether you really read ALL of the related topics, so please forgive me if I suggest something that you have already tried. Could it be that the Sqlite.Interop.dll and other required files are not copied to the Temporary ASP.NET Files folder when IIS is running the website? - Florian Lim
It could be, how can I check to be sure? What location are those files copied to? PS. I'm not running using IIS Express, using Local IIS with an actual virtual directory, so i thought the files shouldn't be copied. And as I mentioned, other sites are working fine on the same laptop. - Quintonn

1 Answers

0
votes

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.