Scitosol
Scitosol

Reputation: 171

"Unable to find an entry point named 'sqlite3_open_interop' in DLL 'SQLite.Interop.dll'."

I am using a C# application to try to connect to a SQLite database. The application uses the library System.Data.Sqlite, version 108. In Visual Studio 2017, my Solution Configuration is Debug, and my Solution Platform is Any CPU. Whenever I build and run the application, I get the following runtime exception:

enter image description here

The exception is unhandled, and the application terminates.

There is, of course, a SQLite.Interop.dll file in my bin\Debug directory. (If there wasn't, the exception would be different.) Specifically, there are two, each in their own subdirectories named x64 and x86. My assumption is that the file in the x86 directory is being used, since the Solution Platform is set to Any CPU. The version of the SQLite.Interop.dll assembly matches that of System.Data.SQLite.dll, being 1.0.108.0.

When I use the following command to interrogate the assemblies:

dumpbin /exports SQLite.Interop.dll

I do find the following line in the output for the x64 version of the assembly:

175   AE 00040750 sqlite3_open_interop

but in the output for the x86 version I do not. Instead, I find this line:

175   26 00037F10 _sqlite3_open_interop@20

which is close, but not a match. So there is indeed no such method as sqlite3_open_interop exposed by the assembly.

I have tried the obvious solution of changing the Solution Platform to x64, but that change leads to another exception (BadImageFormatException) which I don't much want to contend with.

I have tried dropping the reference to System.Data.SQLite and using Nuget to add the most recent version, 1.0.111.0, then cleaning and rebuilding the solution, but all to no effect. The same issue recurs.

Could anyone suggest a solution to this issue? SQLite is widely used, I believe, so I have to think there's a way to work through it.

*Edit1: I tried this project on my home computer, and observed the same difference between the two SQLite.Interop.dll files. The x64 version had a sqlite3_open_interop, while the x86 version had a _sqlite3_open_interop@20. However, the problem did not occur there. So apparently this mangled name "issue" is a red herring. I am still very interested in solving this problem, and would appreciate the assistance of someone who works on System.Data.Sqlite!

Upvotes: 7

Views: 11612

Answers (5)

CAD bloke
CAD bloke

Reputation: 8828

My problem was 2 different plugins within the same host application (AutoCAD) referenced different versions of the SQLite DLL. They need to reference the same version.

Upvotes: 0

Junaid Javed
Junaid Javed

Reputation: 1

I faced a quite similar problem. I know I am late and the problem I faced is somewhat different but I guess someone might find this useful. My problem statement was "Unable to find an entry point named 'sqlite3_config' in DLL 'SQLite.Interop.dll'."

I just checked my SQLite NuGet Package Version. You can find it in your cs.proj file. It looks like this:

<Reference Include="System.Data.SQLite, Version=1.0.115.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Data.SQLite.Core.1.0.115.1\lib\net451\System.Data.SQLite.dll</HintPath>
</Reference>

Just find the SQlite.interop.dll file with the similar or older version for both x86 and x64 folders. Make it part of your build through setup project.

Upvotes: 0

Simon Aleman
Simon Aleman

Reputation: 81

Delete your x64 and x86 directory then do a build. It will put the correct version in the folder when the installer does the NuGet check. For some reason, when you upgrade to a newer version, the x64 and x86 folders do not update the interop file in those folders if one already exists.

Upvotes: 8

S.ATTA.M
S.ATTA.M

Reputation: 497

Though its an old thread but nevertheless someone else may face similar issue again. In my case, this error occurs when I try to make connection string with password, since in the latest version of sqlite, ecnryption has been a paid feature that's why it doesn't work in free version. So, to circumvant this issue I restored old version of sqlite (picked from my old project) and it worked ok.

Add following reference in your project:

  • System.Data.SQLite.dll

Copy following files in binary folder:

  • System.Data.SQLite.dll.config (Optional)

  • System.Data.SQLite.xml (Optional)

  • x64\SQLite.Interop.dll

  • x86\SQLite.Interop.dll

Where 'x64' and 'x86' are folders

  • Packages available on nuget have same issue so you need old dll

Upvotes: 3

Scitosol
Scitosol

Reputation: 171

It turned out the issue was that the assembly was being blocked or disrupted somehow by McAfee Host Intrusion Prevention. The Activity log had the following message:

Attack type: DISA McAfee - Prevent unexpected DLL files from Running in User AppData and ProgramData folders (Sig Id = 7020)

Which is odd because I don't think my program was executing in either such folder; in fact, there are no such folders, as I am looking at the matter. I was able to fix the issue by moving the program to My Documents.

It's also notable that the exception made no hint of interference by a security scanner.

Sigh. I don't know how generally useful this answer is, but I will leave it here. It might help someone. The admins can remove it if they deem appropriate.

Upvotes: 2

Related Questions