未复制到输出目录的引用的依赖关系

Dependencies of references not copied to output directory(未复制到输出目录的引用的依赖关系)
本文介绍了未复制到输出目录的引用的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CommonUtils 库,我已将其构建到一个 dll 中,我从我的几个项目中引用了该库.CommonUtils 依赖于在构建 CommonUtils.dll 时设置为文件引用和 copy-local=true 的 log4net.dll.log4net.dll 和 CommonUtils.dll 不在 GAC 中.

I have a CommonUtils lib I have built into a dll which I file reference from several of my projects. CommonUtils depends on log4net.dll which was set as a file reference and copy-local=true when CommonUtils.dll was built. log4net.dll and CommonUtils.dll are not in GAC.

在 MyWorkingProject 中一切正常,我只有一个对 CommonUtils.dll 的文件引用 - log4net.dll 显示在输出目录中(因为它是 CommonUtils.dll 的依赖项,但未从 MyWorkingProject 引用).但是,如果我创建一个新项目来添加一些单元测试:MyWorkingProjectTest 和项目引用 MyWorkingProject,然后在此处再次文件引用 CommonUtils.dll(我想使用一些 CommonUtils)然后在构建 log4net.dll 时,它是两个项目的依赖项参考和文件参考也不会被复制到输出目录.

Everything works fine in MyWorkingProject where I only have a file reference to CommonUtils.dll - log4net.dll shows up in the output directory (as it is a dependency of CommonUtils.dll but not referenced from MyWorkingProject). However if I create a new project to add some unittests: MyWorkingProjectTest and project reference MyWorkingProject and then file reference CommonUtils.dll again here (I want to use some of the CommonUtils) then upon building log4net.dll which is a dependency in both the project reference and in the file reference as well does not get copied to the output directory.

谁能澄清这里发生了什么?编译器是否不知道它应该抓取哪个 log4net.dll 文件?我在这里做错了什么吗?我应该以其他方式执行此操作以显式复制 log4net.dll 吗?我必须明确引用 log4net 是否有意义?

Can anyone clarify what is happening here? Does the compiler not know which of the log4net.dll files it should grab? Is there something I am doing wrong here? Should I do this in some other way for the log4net.dll to get copied explicitly? Does it make any sense that I have to explicitly reference log4net does it?

推荐答案

这是设计使然.您需要考虑自动继承引用会导致的影响.虽然您可以从逻辑上看到引用应该是什么,但编译器没有这样的描述.从理论上讲,如果它遍历整个依赖关系树,您最终可以复制框架和操作系统的大部分.

This is by design. You need to think about the implications that automatic inheritance of references would cause. While you can logically see what the references should be, there is no such delineation to the compiler. You could, theoretically, end up reproducing the Framework and a good part of your OS if it walked the entire dependency tree.

这绝对是一种痛苦,我同意并理解你的沮丧,但我认为微软无法找到一种合乎逻辑的方式来做到这一点.

It definitely is a pain, and I agree with and understand your frustration, but I assume that Microsoft was not able to find a logical way to do this otherwise.

这篇关于未复制到输出目录的引用的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
quot;Overflowquot; compiler error with -9223372036854775808L(编译器错误-9223372036854775808L(Q;溢出Q))
Visual Studio 2010 ReportViewer Assembly References(Visual Studio 2010 ReportViewer程序集引用)
Weird behaviour when I open a reportviewer in WPF(在WPF中打开报表查看器时出现奇怪的行为)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)