MySoultion
> MyFirstProject(* .exe)
> MySecondPrject(* .dll)
> …
> MyNthProject(* .dll)
每个子项目使用Log4.net.So我创建一个目录(称为LogBinary),并将log4.net dll放在该文件夹中.然后使用log4net我添加这个dll作为我的每个项目的参考…
但是当我尝试编译我的主要项目(* .exe)时,我收到了大量警告(超过400 …)
只是一个例子:
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”
许多警告与
has already been imported from another assembly
为什么我得到这个警告?有没有人有解决方案来添加相同的dll到多个项目(除了使用GAC)
最好的祝愿
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的例子看起来像这样:
Solution -> Log4.net Solution -> Proj1 Solution -> Proj1 -> Log4.net Solution -> Proj2 Solution -> Proj2 -> Log4.net ...
避免警告的方法是将Build中的Use Dependencies设置为false,以便对Proj1,Proj2,..,Projn的所有引用进行设置.