0
votes

Greetings people who are smarter than I.

After publishing a project which utilises SQLite, when the part of the program runs that accesses the DB commands, I get this error.

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

Now I have spent hours, going through the many similar threads, trying all the suggestions to see if I can fix this, however as of yet I have had no luck.

I have done the following.

Ensured the SQLite.Core is included on the main project and all sub project areas.

Ensured the .dll is available in the debug bin.

Ensured dependencies are set correctly.

Publish specifically to x64 platform.

Publish specifically to x86 platform.

Disabled "Prefer 32-bit".

Copied some specific references to csproj.

All to no avail. If anyone has any experience with this who might be able to suggest something new that I haven't tried in an attempt to solve this I would be most grateful.

1
Did you include SQLite.Interop.dll to the installer? - Eugene Astafiev
@EugeneAstafiev, Hey, yeah I believe I did, though I dont want to make assumptions, how would i check that this infact done correctly? - RustyUK
Do you see the assembly on the end-user machine after installing the application? - Eugene Astafiev
@EugeneAstafiev, i dont think so. Where would i put the interop prior to publishing to have it included in the publish? If i put the interop in the debug folder, where the program is publishing from, it breaks the project entirely with read/write errors. - RustyUK

1 Answers

0
votes

So after much research i finally found the solution.

It seems there are a great many potential causes for this error, however this resolved the issue for me in this instance.

Revert everything back to how it was, ensure System.Data.SQLite.Core is referenced in your assemblies.

Close VS / solution and open the csproj file in the repo. Copy the following into the file.

<PropertyGroup> 
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
<CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
<CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
<CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
</PropertyGroup>

Save the file, (probably would create a copy of it beforehand to ensure you can replace it if it doesnt work for you).

Ensure that interop.dll is not anywhere in your repo except bin/debug/x86 and x64.

Then proceed to test your project, then publish it.

Reason:

Because the Interop is included in the nuget installation, but not copied down, this bit of code ensures that its copied through during the publishing.

Thank you internet.