Visual Studio C # - SQLite.Interop.dll not found

I am currently trying to create a Visual Studio C # application using SQLite using Visual Studio. I installed SQLite for my program with NuGet, and three recommendations appeared in the solution explorer (System.Data.SQLite, System.Data.SQLite.EF6, System.Data.SQLite.Linq).

When I run my application in VS, everything works fine. However, whenever I publish it (using ClickOnce) and try to run the application, it crashes with the following error: System.DllNotFoundException: Unable to load the SQLite.Interop.dll DLL: the specified module was not found (exception from HRESULT : 0x8007007E)

After some research, I found this DLL in the Debug folder and copied it to the folder where the ".exe" version of my program was created (after publishing and running "setup.exe"). Thus, the application works well.

But I'm not very happy with this decision, as it seems really dirty. I do not want future users to have to do this manually when they install my application!

So my question is: what can I do to make sure that this DLL is installed with my program?

Note. I tried the first answer of this post: unable to load sqlite dll interop dll WPF But I did not seem to work for me.

Thank!

+5
7

. https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki.

, x86 x64 SQLite.

: , - /.

, . . 1.0.80.0 . , XCOPY (.. , ), , :

  • bin\App.exe (, )
  • bin\App.dll (, )
  • bin\System.Data.SQLite.dll (, )
  • bin\System.Data.SQLite.Linq.dll (, LINQ )
  • bin\System.Data.SQLite.EF6.dll (, EF6 )
  • bin\x86\SQLite.Interop.dll (, x86)
  • bin\x64\SQLite.Interop.dll (, x64)

"bin" , . , , System.Data.SQLite .

+8

Visual Studio 2017 NET Framework 4.5 :

Outlook, ClickOnce SQLite . SQLite NuGet , " DLL" SQLite.Interop.dll "".

, DLL "SQLite.Interop.dll" , . enter image description here

"SQLite.Interop.dll" , "{project}\packages\System.Data.SQLite.Core.1.0.105.2\build \" .Net FrameWork [ TG31]

, DLL , ClickOnce. enter image description here

(: DLL NET Framework .)

+6

dll sqlite.interop.dll SQLite NuGet. , dll, x86 x64. SQLite , DLL. .

+5

. , u , dll .

, SQLLite, (Checkbox) .

, .

0

". : dll sqlite interop dll WPF. , , .

, , . :

  • sqlite.interop.dll , .
  • , "" ( , ) , , .

, .

0

nuget System.Data.SQLite Build , dll . , , nuget, / .

(, , ) PrivateAssets = "None" PrivateAssets = "Analyzers", , Analyzers .

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
    <RootNamespace>MyNamespace</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ServiceStack.OrmLite.Sqlite.Core" Version="5.6.0" />
    <PackageReference Include="System.Data.SQLite.Core" Version="1.0.111"  PrivateAssets="Analyzers" />
   </ItemGroup>

</Project>
0

SQlite.Interop , :

  1. VS : Sqlite.Interop.dll :.\bin\Debug\x86 \bin\Debug\x64

  2. Select the properties and set the compilation action to "Content" and copy to the output directory = "Always copy"

  3. rebuild

0
source

Source: https://habr.com/ru/post/1649188/


All Articles