Visual Studio 2010正在吃我的DLL! - 构建后缺少引用的第三方dll [英] Visual Studio 2010 is Eating My DLLs! - referenced third party dlls missing after build

查看:251
本文介绍了Visual Studio 2010正在吃我的DLL! - 构建后缺少引用的第三方dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我拉出我的头发:



我有一个Visual Studio ASP.NET MVC解决方案,其中项目引用第三方DLL,在这种情况下,code> log4net 我的解决方案树如下:




  • GenericLibrary

  • MyApp.NHibernate

  • MyApp.Library

  • MyApp.WebUI



MyApp。 WebUI 是主要的启动MVC Web项目,并且引用了 GenericLibrary ,MyApp.NHibernate 和 MyApp.Library 。 MyApp.NHibernate 引用了所有的NHibernate位,包括log4net。



现在问题是当我编译我的解决方案时,log4net dll似乎出现并从MyApp.WebUI项目的/ bin目录中消失,因此NHibernate可以理解错误。我的第二个监视器上有一个Windows资源管理器窗口,看着web项目的/ bin文件夹,我可以看到log4net dll出现,然后每次编译后消失,似乎顺序发生(出现,消失,重新出现,消失等),而不是随机。



MyApp.NHibernate项目是唯一引用log4net dll的项目,但GenericLibrary有一个引用NHibernate但不是log4net。 MyApp.NHibernate引用了GenericLibrary,MyApp.Library也引用了GenericLibrary,但是GenericLibrary是独立的。



我可以想到的唯一的解决方案是将主要的MyApp.WebUI在我的解决方案(Nhibernate,log4net,Castle Windsor等)中使用的每个外部库/ dll的项目,以修复log4net问题,并避免将来发生这种情况。但是这对我来说并不是一个非常整洁/解耦的解决方案。






更新:要回答kekekela的问题,我将Copy Local设置为true用于log4net引用和MyApp.NHibernate项目引用本身,请参见下面的屏幕截图:



alt text http://www.dominicpettifer.co.uk/Temp/DLL-Hell-1.png






更新2: Bizzarely这个问题似乎只会影响log4net dll。我尝试添加不同的第三方dll到MyApp.NHibernate项目,NLog dll,这似乎保持放置,而log4net继续消失并重新出现。

解决方案

我有同样的问题。我将项目属性对话框中的目标框架从.NET Framework 4客户端配置文件更改为.NET Framework 4,这似乎可以解决问题。以下是描述目标框架差异的 msdn 文章。 p>

Please help I am pulling my hair out over this:

I have a Visual Studio ASP.NET MVC solution in which a project references a third party DLL, log4net in this case. My solution tree is as follows:

  • GenericLibrary
  • MyApp.NHibernate
  • MyApp.Library
  • MyApp.WebUI

MyApp.WebUI is the main start-up MVC web project and has references to GenericLibrary, MyApp.NHibernate and MyApp.Library. MyApp.NHibernate has references to all the NHibernate bits including log4net.

Now the problem is when I compile my solution the log4net dlls seem to appear and disappear from the MyApp.WebUI project's /bin directory, so NHibernate throws errors understandibly. I've had a Windows Explorer window on my second monitor looking at the web project's /bin folder, and I can see the log4net dll appear then disappearing after each compile, it seems to happen in sequence (appear, disappear, re-appearm, disappear etc.) rather than randomly.

MyApp.NHibernate project is the only project which references the log4net dll, but GenericLibrary has a reference to NHibernate but NOT log4net. MyApp.NHibernate references GenericLibrary, MyApp.Library also references GenericLibrary, but GenericLibrary stands alone.

The only solution I can think of is to add References to the main MyApp.WebUI project for every external library/dll used in my solution (Nhibernate, log4net, Castle Windsor etc.), to fix the log4net issue and avoid this happening in future. But that's not a very neat/decoupled solution to me.


Update: To answer kekekela's question, I have Copy Local set to true for both log4net reference and the MyApp.NHibernate project reference itself, see screenshot below:

alt text http://www.dominicpettifer.co.uk/Temp/DLL-Hell-1.png


Update 2: Bizzarely this problem only seems to effect log4net dll. I tried adding a different 3rd party dll to the MyApp.NHibernate project, the NLog dll, this seems to stay put whereas the log4net continues to disappear and re-appear.

解决方案

I was having this same issue. I changed the target framework in the project's properties dialog from ".NET Framework 4 Client Profile" to ".NET Framework 4" which seems to solve the problem. Here is an msdn article describing the differences in the target frameworks.

这篇关于Visual Studio 2010正在吃我的DLL! - 构建后缺少引用的第三方dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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