Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

十年热恋 提交于 2020-01-01 05:36:34

问题


I have integrated my project with another one (MVC3 application). Then I'm getting below error. Both the projects are working fine with the Microsoft Enterprise Library version 5.2.414.0. After integrating only some of the pages are working and remaining pages throwing below exception.

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.


回答1:


This usually happens if the reference does not have "CopyLocal" flag set to true.

To solve:

  1. Open your solution
  2. Expand until you find your project
  3. Expand references
  4. Select the mentioned assembly
  5. Right-click and press properties (or press F4)
  6. Where it says "Copy local" set it to true

Also, this can happen if you are missing the other enterprise library blocks needed by the mentioned assembly (and copy local true as well), which are:

  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.ServiceLocation.dll
  • Microsoft.Practices.Unity.Configuration.dll
  • Microsoft.Practices.Unity
  • Microsoft.Practices.Unity.Interception.Configuration
  • Microsoft.Practices.Unity.Interception



回答2:


Just remove all related DLL (Microsoft.Practices.*.dll) files from your bin folder and rebuild the solution.




回答3:


Check if the project where you imported Enterprise Library 5 DLLs relies on .NET Framework 4. I was struggling with the same error, but with EL 6. Since my entire project relies on .NET 4 and EL 6 is developed using .NET 4.5, my application was crashing on every startup.

EL 5 uses .NET Framework 4 and is compatible with 3.5 too (EL 5 setup tells you this info). EL 6 uses .NET Framework 4.5 or 4.5.1 (not sure, but downgrading to EL 5 made my project work).



来源:https://stackoverflow.com/questions/21236223/could-not-load-file-or-assembly-microsoft-practices-enterpriselibrary-data-ver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!