简体   繁体   English

跨多个项目的 NuGet 包

[英]NuGet package across mutliple projects

I have a project which I used to create the handling of a SqLite3 database.我有一个项目,用于创建 Sqlite3 数据库的处理。 This project gets consumed by multiple other projects which in turn gets consumed by the UI project.这个项目被多个其他项目使用,而这些其他项目又被 UI 项目使用。 I only added the Nuget package to the project handling the SqLite3 interfacing.我只将 Nuget 包添加到处理 Sqlite3 接口的项目中。

When I attempt to run the UI, it makes calls to get information from the database, and when this happens I get a System.DllNotFoundException for SQLite.Interop.dll.当我尝试运行 UI 时,它会调用从数据库中获取信息,当发生这种情况时,我会收到 SQLite.Interop.dll 的 System.DllNotFoundException。

So how do I force this to work without having to add the Nuget package to all the projects in the solution?那么如何在不必将 Nuget 包添加到解决方案中的所有项目的情况下强制执行此操作?

Maybe your issue is similar to this one which often occurs when using Sqlite in WPF projects.也许你的问题类似于这一个,其在WPF项目使用SQLite时经常发生。

It seems that SQLite uses the entry assembly to detect which version of Interop to load.似乎 SQLite 使用入口程序集来检测要加载哪个版本的互操作。

And for your situation, the easy ways you can try to resolve it ( Make the backup first ):对于您的情况,您可以尝试解决它的简单方法(首先进行备份):

  1. Right-click your UI project=>Properties=>Build=>disable the Prefer 32-bit or change the platform target from Any CPU to X64 or X86 .右键单击您的UI project=>Properties=>Build=>disable the Prefer 32-bit或将platform target from Any CPU to X64 or X86更改platform target from Any CPU to X64 or X86

在此处输入图片说明

  1. You don't have to add the nuget to all your projects in the solution, adding it to the UI project(The main project which is set as StartUp project in your solution) is enough I think.您不必将 nuget 添加到解决方案中的所有项目中,我认为将其添加到 UI 项目(在您的解决方案中设置为 StartUp 项目的主项目)就足够了。

  2. Also, you can try Wil's answer ,what you need to do is: create x64 and x86 folders in your UI Project Directory(where the xx.csproj exists)=>find and copy the SQLite.Interop.dll for x64 and x86 to corresponding folders.此外,您可以尝试Wil 的回答,您需要做的是:在您的 UI 项目目录中创建x64 and x86文件夹(xx.csproj 存在的位置)=> 查找并复制 x64 和 x86 的SQLite.Interop.dll到相应的文件夹。 Then in VS, right-click UI project=> unload UI project and edit xx.csproj =>copy the working-version script into the xx.csproj file, and reload the UI project.(copy the ItemGroup script within <Project> tag )然后在VS中,右键UI项目=> unload UI projectedit xx.csproj =>将工作版本脚本复制到xx.csproj文件中,并重新加载UI项目。(复制within <Project> tag的ItemGroup脚本)

Remember to rebuild the project before you run the app.请记住在运行应用程序之前重建项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM