添加相同" *。dll的"参考多个项目在同一解决方案 [英] Adding same "*.dll" reference to multiple projects in the same Solution

查看:129
本文介绍了添加相同" *。dll的"参考多个项目在同一解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio .NET 2008 C ++ / CLI解决方案。我的解决方案包含许多子项目。我定义为每个项目调用它的输出定制打造专业化目录。

I have a Visual Studio 2008 .NET C++/CLI Solution. My Solution consist of many sub projects. I define a custom buid directory for each project call it Output.

MySoultion

MySoultion

  • MyFirstProject文件(* .exe)
  • MySecondPrject(* .dll文件)
  • ...
  • MyNthProject(* .dll文件)

每个子项目使用Log4.net.So我创建一个目录(称为LogBinary),并把log4.net DLL在folder.Then使用log4net的我添加此DLL作为参考,我的每个项目的.. 。 但是,当我尝试编译我的主要项目文件(* .exe)我得到警告(400 ...)

Each of the sub project use Log4.net.So I create a directory (called LogBinary) and put log4.net dll in that folder.Then to use log4net i add this dll as a reference to each of my project... But when i try to compile my main project (*.exe) i got tons of warning ( over 400...)

只是一个例子:

警告110警告C4945:'AbsoluteTimeDateFormatter:   无法从导入符号somepath \ log4net.dll:作为   log4net的:: DateFormatter :: AbsoluteTimeDateFormatter   已经从其他组件进口log4net的'somepath \ log4net.dll

Warning 110 warning C4945: 'AbsoluteTimeDateFormatter' : cannot import symbol from 'somepath\log4net.dll': as 'log4net::DateFormatter::AbsoluteTimeDateFormatter' has already been imported from another assembly 'log4net'"somepath\log4net.dll"

许多与警告

已经从其他组件进口

为什么我得到这个警告?是否有人有elagant解决方案,以同一个DLL添加到多个项目(除使用GAC)

Why i got this warnings? Does anybody has elagant solution to add same dll to multiple projects (except using GAC)

最良好的祝愿

推荐答案

我终于找到了一个解决这个问题,这并不觉得自己是一个黑客。我发现,在<一个答案href="http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/63efd1d6-bee1-4acc-95de-1f76a784d158"相对=nofollow>从pyro_serv`在MSDN社交网站的响应:

I finally found a solution to this problem which doesn't feel like a hack. I found the answer in a response from 'pyro_serv` on the msdn social site:

解决方法是使用使用依赖关系在构建和使用在Build标志上的每个VC项目引用(通过VC属性页),并切换到适合您的情况来解决此错误。

The fix is to use the "Use Dependencies In Build" and "Use In Build" flags on each VC project references (via the VC properties sheet), and toggle them as appropriate for your case to resolve this error.

因此​​,对于它看起来像这样的OP的例子:

So for the OP's example which looks something like this:

Solution -> Log4.net
Solution -> Proj1
Solution -> Proj1 -> Log4.net
Solution -> Proj2
Solution -> Proj2 -> Log4.net
...

要避免警告的方式是设置使用依赖于构建为false所有引用了 Proj1,Proj2,.., Projn

The way to avoid the warnings is to set Use Dependencies in Build to false for all of the references to Proj1,Proj2,..,Projn.

我刚刚验证了这一点的,演示解决方案,它的伟大工程 - !我怎么也不敢相信简单的解决方法是多少时间,我已经浪费了找到它

I've just verified this with a demo solution and it works great - I can't believe how simple the solution is and how much time I've wasted to find it!

这篇关于添加相同&QUOT; *。dll的&QUOT;参考多个项目在同一解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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