为什么我找不到需要引用的Enterprise程序集?

时间:2016-02-11 14:18:20

标签: asp.net visual-studio .net-assembly enterprise-library

我正在开发Visual Studio应用程序,我想使用数据访问应用程序块,它是Microsoft Enterprise库5.0的一部分。我一直在按照this guide中的步骤安装数据访问应用程序块。 this page上有一个步骤要求我引用以下程序集:

Microsoft.Practices.EnterpriseLibrary.Data.dll

Microsoft.Practices.EnterpriseLibrary.Common.dll

Microsoft.Practices.Unity.dll

Microsoft.Practices.ServiceLocation.dll

Microsoft.Practices.Unity.Interception.dll

问题在于,当我尝试添加它们时,我看不到它们在参考管理器中的任何位置列出。

有人可以向我解释为什么我看不到它们/我怎么能找到它们?

由于

1 个答案:

答案 0 :(得分:1)

下载所需程序集的最简单方法是使用NuGet安装Data Access Application Block

在Visual Studio中(不确定您使用的是哪个版本 - 这适用于Visual Studio 2013),转到“菜单”并选择“工具” - >“NuGet包管理器” - >“包管理器控制台”。控制台应该出现。如果没有,则选择View-> Other Windows-> Package Manager Console。

接下来在Package Manager控制台中输入:

  

PM> Install-Package EnterpriseLibrary.Data -Version 5.0.505

这将安装以前的(版本5)数据访问应用程序块及其所有依赖项。您应该在程序包管理器控制台中看到以下内容

Attempting to resolve dependency 'EnterpriseLibrary.Common (≥ 5.0)'.
Attempting to resolve dependency 'Unity.Interception (≥ 2.1)'.
Attempting to resolve dependency 'Unity (≥ 2.1)'.
Attempting to resolve dependency 'CommonServiceLocator (≥ 1.0)'.
Installing 'CommonServiceLocator 1.0'.
Successfully installed 'CommonServiceLocator 1.0'.
Installing 'Unity 2.1.505.0'.
You are downloading Unity from Microsoft patterns & practices, the license agreement to which is available at http://www.opensource.org/licenses/ms-pl. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Unity 2.1.505.0'.
Installing 'Unity.Interception 2.1.505.0'.
You are downloading Unity.Interception from Microsoft patterns & practices, the license agreement to which is available at http://www.opensource.org/licenses/ms-pl. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Unity.Interception 2.1.505.0'.
Installing 'EnterpriseLibrary.Common 5.0.505.0'.
You are downloading EnterpriseLibrary.Common from Microsoft, the license agreement to which is available at http://www.opensource.org/licenses/ms-pl. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EnterpriseLibrary.Common 5.0.505.0'.
Installing 'EnterpriseLibrary.Data 5.0.505.0'.
You are downloading EnterpriseLibrary.Data from Microsoft, the license agreement to which is available at http://www.opensource.org/licenses/ms-pl. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EnterpriseLibrary.Data 5.0.505.0'.
Adding 'CommonServiceLocator 1.0' to ConsoleApplication1.
Successfully added 'CommonServiceLocator 1.0' to ConsoleApplication1.
Adding 'Unity 2.1.505.0' to ConsoleApplication1.
Successfully added 'Unity 2.1.505.0' to ConsoleApplication1.
Adding 'Unity.Interception 2.1.505.0' to ConsoleApplication1.
Successfully added 'Unity.Interception 2.1.505.0' to ConsoleApplication1.
Adding 'EnterpriseLibrary.Common 5.0.505.0' to ConsoleApplication1.
Successfully added 'EnterpriseLibrary.Common 5.0.505.0' to ConsoleApplication1.
Adding 'EnterpriseLibrary.Data 5.0.505.0' to ConsoleApplication1.
Successfully added 'EnterpriseLibrary.Data 5.0.505.0' to ConsoleApplication1.

另一种方式是download Enterprise Library,然后从安装位置引用各个程序集。

相关问题