Unable to load dll 'SQLite.interop.dll' after installing my app. The dll is present in the application folder
(1) By anonymous on 2021-03-12 13:13:37 [source]
I've found some similar question to this but not quite the same as mine (they're mostly resolved by ensuring the interop is successfully copied to the correct application folder which is already true in my case).
I have an WPF app with a dependency on SQLite. It works fine on my development machine, both from visual studio (2017) and when installed.
I've built an msi package using InstallShield to install it on customer machines. SQLite.Interop.dll has been included in the files to be copied to the application directory along with System.Data.SQLite.dll and System.Data.SQLite.xml. This appears to run successfully and does copy all of these files into the application folder successfully. However, when I run the application I get the error in the title. This happens when I make a call to SQLiteConnection.SQLiteVersion but I'm pretty sure this is just because that's the first interaction the app has with SQLite.
The really weird thing is that installing Visual Studio on the target machine makes the problem go away. My best guess is that there is some underlying dependency that's not being set up on the target machine by my msi but which installing VisualStudio does include, thus resolving the dependency for SQLite. That's a total guess though.
Can anyone suggest a solution?
Edit> I should add that the application is being built explicitly as x64. I noticed a few people had problems when using AnyCPU but that doesn't apply in my case.
(2) By Decker (d3x0r) on 2021-03-12 16:40:16 in reply to 1 [link] [source]
I suspect the C/C++ VS runtime isn't installed on the target.
(3) By TripeHound on 2021-03-12 16:48:42 in reply to 1 [link] [source]
Have a look at the System.Data.SQLite Downloads page... there (usually) is a dependency on the Microsoft Visual C++ Runtime Library. Installing Visual Studio will get these (as you found), but there are downloads from Microsoft of just the library, which you'd need to include in the MSI or deploy manually. There also appear to be (from skimming that page) "static" versions of the packages that don't have the dependency on the runtime libraries (but will, therefore, be bigger, I assume).
(4) By anonymous on 2021-03-15 14:53:48 in reply to 3 [link] [source]
That was it. A VC Redist was actually already being included in the install but it was an older version than the one required to support the version of SQLite we're now using. I was able to look up the version of SQLite version we're using and simply read the description from the page you linked to see what the problem was. I've simply included the correct redist in the package and everything's now zipping along just fine.
Thank you both for your help. I'd been trying to figure this out for a week and you got me there over a single weekend :)
(5) By Larry Brasfield (larrybr) on 2021-03-15 15:12:35 in reply to 4 [link] [source]
For future reference: The DLL Dependency Walker tool is good for seeing things like the problem you had. If you see dependency upon any DLL not in the deployment directory, then you know that something more needs to be there. Typically, this problem will show as a used DLL living in its installation directory within the dev tools.