依赖DLL未被复制到Visual Studio中的构建输出文件夹 [英] Dependent DLL is not getting copied to the build output folder in Visual Studio

查看:155
本文介绍了依赖DLL未被复制到Visual Studio中的构建输出文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视觉工作室解决方案。
我在解决方案中有很多项目。
有一个主要项目作为启动并使用其他项目。
有一个项目说ProjectX。其参考资料加入主体工程。
ProjectX引用不是解决方案一部分的另一个.NET DLL(例如abc.dll)。



现在这个abc.dll应该被复制到主项目的bin / debug文件夹,但是没有被复制到那里。为什么没有被复制,任何已知的原因?

解决方案

我发现如果ProjectX引用了abc.dll但没有直接使用abc.dll中定义的任何类型,然后abc.dll不会被复制到主输出文件夹。 (它将被复制到ProjectX输出文件夹,使其变得混乱)。



所以,如果你没有明确地使用abc的任何类型。 dll在ProjectX的任何地方,然后在ProjectX中的一个文件中放置一个虚拟声明。

  AbcDll.AnyClass dummy006; //这将足以导致DLL复制

您不需要这样做对于每个课程 - 只需一次就足够使DLL副本和一切按预期工作。



附录:请注意,这可能会工作用于调试模式,但不能发布。详见@ nvirth的答案。


I have a visual studio solution. I have many projects in the solution. There is one main project which acts as the start up and uses other projects. There is one project say "ProjectX". Its reference is added to main project. The ProjectX references another .NET dll (say abc.dll) that isn't part of the solution.

Now this abc.dll should be copied to bin/debug folder of main project, but it isn't getting copied there. Why is it not getting copied, any known reasons ?

解决方案

I found that if ProjectX referenced the abc.dll but didn't directly use any of the types DEFINED in abc.dll, then abc.dll would NOT be copied to the main output folder. (It would be copied to the ProjectX output folder, to make it extra-confusing.)

So, if you're not explicitly using any of the types from abc.dll anywhere in ProjectX, then put a dummy declaration somewhere in one of the files in ProjectX.

AbcDll.AnyClass dummy006; // this will be enough to cause the DLL to be copied

You don't need to do this for every class -- just once will be enough to make the DLL copy and everything work as expected.

Addendum: Note that this may work for debug mode, but NOT for release. See @nvirth's answer for details.

这篇关于依赖DLL未被复制到Visual Studio中的构建输出文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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