【问题标题】:The type or namespace name 'Practices' does not exist in the namespace 'Microsoft'命名空间“Microsoft”中不存在类型或命名空间名称“Practices”
【发布时间】:2013-05-04 16:42:10
【问题描述】:

我正在使用 Microsoft Visual Studio 2005 for c# 我的代码中有以下命名空间

using Microsoft.Practices.EnterpriseLibrary;
using Microsoft.Practices.EnterpriseLibrary.AppSettings;
using Microsoft.Practices.EnterpriseLibrary.Data;

我不断收到此错误:

-命名空间“Microsoft”中不存在类型或命名空间名称“Practices”(您是否缺少程序集引用?)

我该怎么办?

提前致谢。 :)

【问题讨论】:

标签: c# visual-studio namespaces enterprise-library


【解决方案1】:

除了引用项目中的 DLL,还要确保项目属性中的 Target Framework 至少与 Microsoft Enterprise Library 版本一样高:

还要确保它没有设置为客户端配置文件(例如 .NET Framework 3.5 客户端配置文件),否则您也会收到相同的错误。

顺便说一句,下载 Enterprise Library 6.0:

  • 运行自解压可执行文件EnterpriseLibrary6-binaries.exe
  • 在 PowerShell 中运行下载脚本:
    • 启动管理员命令提示符
    • 导航到包含install-packages.ps1的目录
    • 使用命令powershell -ExecutionPolicy ByPass -File install-packages.ps1

对于 5.0,如果您不想安装 DLL,可以下载 MSI 并使用Universal Extractor

【讨论】:

    【解决方案2】:

    您应该从您的项目中添加对企业库的引用。您可以在此处下载 dll: http://msdn.microsoft.com/en-us/library/ff648951.aspx

    【讨论】:

    • Nuget 是另一种选择,而不是下载程序集。
    • 是的,这也是我推荐的解决方案,但据我所知,没有官方的 VS2005 支持 nuget。或者有吗?
    • 好点。根据stackoverflow.com/a/7558894/254973 的说法,有一种疯狂的方式可以拼凑一些东西。但这可能更麻烦,因为如果其他人需要使用该项目,它会创建更多的外部工作。它是组件!
    • 啊,我不知道 Scotts 的文章,很高兴知道。您始终可以在 VS 环境之外运行 nuget.exe 来获取文件,但正如您已经提到的:如果您正在运行 VS2005,只需下载库会更容易。
    • 我应该下载什么版本?
    【解决方案3】:

    当我将“目标框架”从“.Net Framework 4 Client Profile”更改为“.Net Framework 4”时,同样的问题得到了解决。

    【讨论】:

      【解决方案4】:

      Visual Studio 2005 仅支持原始 .NET 2.0 项目。

      您可以从this page 看到,目前只有少数版本处于活动状态,

      • 企业库 6 - 2013 年 4 月
      • 企业库 5.0 - 2010 年 4 月
      • 适用于 Windows Azure 的 Enterprise Library 5.0 集成包 - 2011 年 11 月
      • 适用于 Silverlight 的 Enterprise Library 5.0 集成包 - 2011 年 5 月
      • Enterprise Library 4.1 - 2008 年 10 月

      即使是 4.1,Visual Studio 2008 and above is required

      支持 Visual Studio 的最后一个版本是 the 3.1 release,已经 6 岁了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-09
        • 2018-06-14
        • 2021-07-28
        • 2015-01-05
        • 1970-01-01
        • 2017-12-29
        • 2014-04-12
        相关资源
        最近更新 更多