DLL 引用未复制到项目 bin [英] DLL reference not copying into project bin

查看:24
本文介绍了DLL 引用未复制到项目 bin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Project A 引用了 Project BProject B 引用外部 DDL(使用 NuGet 恢复).DLL 应该被复制到 Project A 的 bin 文件夹(连同 Project B 的 DLL):

Project A references Project B, and Project B references an external DDL (restored using NuGet). The DLL should get copied into Project A's bin folder (along with Project B's DLL):

就我而言,在运行 Project A 时,我抛出以下异常:

In my case, when running Project A, I get the following exception thrown:

无法加载文件或程序集 'PostSharp,版本 = 3.2.18.0,Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' 或其中之一依赖关系.系统找不到指定的文件.

Could not load file or assembly 'PostSharp, Version=3.2.18.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' or one of its dependencies. The system cannot find the file specified.

未将 DLL 复制到 Project A 的 bin.项目 B 中的所有其他外部引用都被很好地复制了,这让我感到困惑.

The DLL is not being copied into Project A's bin. All other external references from Project B are being copied across just fine, which is what is confusing for me.

Copy Local 设置为 true.示例:

Copy Local is set to true for all references involved. Example:

我该怎么做?

注意:使用 Visual Studio 2013.

Note: Using Visual Studio 2013.

推荐答案

我发现的选项是:

  • 在项目 A 中添加对 PostSharp 的引用.
  • 在项目 B 中添加虚拟代码,以便编译器检测到正在使用引用.
  • 添加构建事件以强制复制 DLL.

我不喜欢上述任何解决方案.在我看来,它们是黑客行为,从长远来看只会导致更难以维护的解决方案.

I don't like any of the above solutions. They are hacks in my opinion and will only make for a more unmaintainable solution in the long run.

我已通过使用通用输出目录解决了该问题.这似乎是许多人推荐的解决方案.我也经历了更快的构建时间.请参阅这篇 Stackoverflow 帖子.

I have fixed the problem by using a common output directory. This seems to be a recommended solution by many. I have also experienced much faster build times. See this Stackoverflow post.

这篇关于DLL 引用未复制到项目 bin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆