C# 命名空间“Microsoft”中不存在类型或命名空间名称“实践”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16474769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:05:49  来源:igfitidea点击:

The type or namespace name 'Practices' does not exist in the namespace 'Microsoft'

c#visual-studionamespacesenterprise-library

提问by QKWS

I am using Microsoft Visual Studio 2005 for c# I have the following namespace on my code

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

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

and I keep on getting this error:

我不断收到此错误:

-The type or namespace name 'Practices' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

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

What should I do?

我该怎么办?

Thanks in advance. :)

提前致谢。:)

采纳答案by Chief Wiggum

You should add a reference to the enterprise library from your project. You can download the dlls here: http://msdn.microsoft.com/en-us/library/ff648951.aspx

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

回答by Lex Li

Visual Studio 2005 only supports raw .NET 2.0 projects.

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

You can see from this pagethat right now only a few releases are active,

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

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

Even for 4.1, Visual Studio 2008 and above is required.

即使对于 4.1,也需要 Visual Studio 2008 及更高版本

The last release supporting Visual Studio is the 3.1 releasewhich is 6 years old.

支持 Visual Studio 的最后一个版本是3.1 版本,它已有 6 年的历史。

回答by SharpC

As well as referencing the DLLs from the project, also make sure that the Target Framework in the project properties are at least as high as the Microsoft Enterprise Library version:

除了从项目中引用 DLL 之外,还要确保项目属性中的目标框架至少与 Microsoft 企业库版本一样高:

Also make sure it's notset to Client Profile (e.g. .NET Framework 3.5 Client Profile) otherwise you will also get the same error.

还要确保它没有设置为 Client Profile(例如 .NET Framework 3.5 Client Profile),否则你也会得到同样的错误。

As an aside, to download the Enterprise Library 6.0:

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

  • run the self-extracting executable EnterpriseLibrary6-binaries.exe
  • run download script in PowerShell:
    • start an Administrator command prompt
    • navigate to the directory containing install-packages.ps1
    • use the command powershell -ExecutionPolicy ByPass -File install-packages.ps1
  • 运行自解压可执行文件 EnterpriseLibrary6-binaries.exe
  • 在 PowerShell 中运行下载脚本:
    • 启动管理员命令提示符
    • 导航到包含的目录 install-packages.ps1
    • 使用命令 powershell -ExecutionPolicy ByPass -File install-packages.ps1

For 5.0, you can download the MSI and use Universal Extractorif you don't want to install the DLLs.

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

回答by Ghouse Barq

The same issue is resolved for me when I changed my "Target Framework" from ".Net Framework 4 Client Profile' to '.Net Framework 4'.

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