0

.NET Framework project - added SQLite to my project via Nuget package, app.config and package.config look correct.

Errors is:- "Type : System.IO.FileNotFoundException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Could not load file or assembly 'System.Data.SQLite, Version=1.0.115.5, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The system cannot find the file specified."

All projects targeting x86

Packages.config

<packages>
   <package id="EntityFramework" version="6.4.4" targetFramework="net471" />
   <package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.115.5" targetFramework="net471" />
   <package id="System.Data.SQLite" version="1.0.115.5" targetFramework="net471" />
   <package id="System.Data.SQLite.Core" version="1.0.115.5" targetFramework="net471" />
   <package id="System.Data.SQLite.EF6" version="1.0.115.5" targetFramework="net471" />
   <package id="System.Data.SQLite.Linq" version="1.0.115.5" targetFramework="net471" />
</packages>

I have tried links below and so many others but nothing working - what am I missing?

Could not load file

Could not load file or assembly 'System.Data.SQLite'

enter image description here

Ram
  • 527
  • 1
  • 10
  • 26
  • Which version is actually in your bin folder? This typically happens if you have multiple projects linking different versions of the Sqlite nuget. – PMF Nov 19 '21 at 17:12
  • @PMF It has the correct version - updated my post to include the version – Ram Nov 19 '21 at 17:41

1 Answers1

0

I recently had a similar problem when I upgraded from 1.0.113 to 1.0.115. It appears that the dependent native binaries are not correctly copied any more.

Adding these two lines to the post build step of a project (doesn't really matter which one in your solution) helped:

xcopy /s /y "%USERPROFILE%\.nuget\packages\Microsoft.SqlServer.Compact\4.0.8876.1\NativeBinaries\amd64\*.*" "$(TargetDir)"
xcopy /s /y "%USERPROFILE%\.nuget\packages\Stub.System.Data.SQLite.Core.NetFramework\1.0.115\build\net46\*.dll" "$(TargetDir)"

(Maybe you need to adapt the lines, depending on the package version used and the .NET version targeted)

EDIT Since you are still using packages.config, the above copy instructions should probably be changed to:

xcopy /s /y "$(SolutionDir)\packages\Microsoft.SqlServer.Compact\4.0.8876.1\NativeBinaries\amd64\*.*" "$(TargetDir)"
xcopy /s /y "$(SolutionDir)\packages\Stub.System.Data.SQLite.Core.NetFramework\1.0.115\build\net46\*.dll" "$(TargetDir)"
PMF
  • 14,535
  • 3
  • 23
  • 49
  • I will try this and let you know if it works... – Ram Nov 20 '21 at 12:44
  • I added the last line - ( we are removing SQLserver.Compact ) and the same error persists... – Ram Nov 22 '21 at 14:31
  • Do you have a file named `SQLite.Interop.dll` in your bin folder or a subfolder of it? – PMF Nov 22 '21 at 14:40
  • Only in the packages folder – Ram Nov 22 '21 at 14:46
  • Oh, I just see that you're still using `packages.config`. Then you need to adapt the copy steps. You basically need to cpy the two files `x86\SQLite.Interop.dll` and `x64\SQLite.Interop.dll` from the `Stub.System.Data.SQLite.Core.NetFramework` package to your bin directory. – PMF Nov 22 '21 at 14:54