添加相同" *。dll的"参考多个项目在同一解决方案多个、解决方案、项目、在同一

由网友(没钱充会员.)分享简介:我有一个Visual Studio .NET 2008 C ++ / CLI解决方案。我的解决方案包含许多子项目。我定义为每个项目调用它的输出定制打造专业化目录。I have a Visual Studio 2008 .NET C++/CLI Solution. My Solution consist of many...

我有一个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 'somepathlog4net.dll': as 'log4net::DateFormatter::AbsoluteTimeDateFormatter' has already been imported from another assembly 'log4net'"somepathlog4net.dll"

许多与警告

已经从其他组件进口的

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

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

最良好的祝愿

推荐答案

我终于找到了一个解决这个问题,这并不觉得自己是一个黑客。我发现,在从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!

阅读全文

相关推荐

最新文章