Unable to load DLL 'SQLite.Interop.dll'

Posted by Blake on 3/1/2018

I was having issues the other day deploying an ASP.Net Core site that made use of the SQLite Nuget package that is meant to work on both x86 and x64 builds. Locally everything worked great but once it was published it failed on the server with this exception:

Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found.

When I inspected the published files and compared them to my local build I noticed that my local build had x64 and an x86 folders that didn't exist on the server. Inside each of these folders was an identically named "SQLite.Interop.dll". In short, the "System.Data.SQLite.dll" file determines if it's running in x64 or x86 and then loads the appropriate interop. The catch is, it actually has to be deployed to the server when it's published. To test, I manually copied these folders out and the site started working correctly.

Here is the solution I used to get those files to copy out (I initially looked at just copying the files out but stumbled upon what is probably the better solution. In Visual Studio, edit your the "csproj", you can right click on it and VS should offer you a menu item to open it up as a text file. Add this section:


After adding this, you should see these appear in the solution explorer as links and when you publish those folders will now be copied to the server. It should probably be a little more straightforward since it seems like a common use case but it's not, so hopefully this helps you if you've found this blog entry.