HttpUtility 在当前上下文中不存在

我在编译 C # 应用程序时遇到了这个错误,看起来像是一个小错误,但我无法避免。

我的设置是 Windows 764位.Visual-Studio 2010 C # Express B2Rel。

我添加了一个对 System 的引用。Dll 位于 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0,但是它有一个黄色的感叹号,我仍然得到上面的错误。我还有 using System.Web的声明。

我做错了什么?


更新: 在得到指向根本原因的提示性答案后,我在谷歌上搜索了一下指向系统的位置。Dll 用于完整的框架。我没有找到这样的参考。
对于像我这样的新手来说,这个 blog 很好地总结了框架(客户端和完整框架)之间的差异。我找不到说明某个 Dll 是否在客户机框架中受支持的地方。我想 Visual Studio 的叹号应该是第一个信号..。

143986 次浏览

You're probably targeting the Client Profile, in which System.Web.dll is not available.

You can target the full framework in project's Properties.

You need to add the System.Web reference;

  1. Right click the "Reference" in the Solution Explorer
  2. Choose "Add Reference"
  3. Check the ".NET" tab is selected.
  4. Search for, and add "System.Web".

SLaks has the right answer... but let me be a bit more specific for people, like me, who are annoyed by this and can't find it right away :

Project -> Properties -> Application -> Target Framework -> select ".Net Framework 4"

the project will then save and reload.

I had the same problem what I did, I copied web.dll from Microsoft.NET framework, then paste in root of project, then add dll refrence to app, it worked

Agrega System.web a las referencias del proyecto.

[Edit]

According to Google Translate, this translates to:

Add System.Web to the project references.

In order to resolve this, Kindly go to the below path

Project-->Properties-->Application-->TargetFramework

and change the Framework to ".NET Framework 4".

Once you do this, the project will close and re-open.

This should solve the error.

In order to resolve this, Kindly go to the below path

Project-->Properties-->Application-->TargetFramework

and change the Framework to ".NET Framework 4".

Once you do this, the project will close and re-open.

This should solve the error

(but for some reason @Karan Modi's answer does not...)

next right-click the references tab in the solution explorer and choose add reference,

choose "System.Web"

(declaring the namespace directly by "using System.Web;" doesnt seems to be enough...you have to add it to the solution explorer...i cant understand why - which is no surprise because i am a cobol programmer..

After following the answers above , and did

Project -> Properties -> Application -> Target Framework -> select ".Net Framework 4"

It still didn't work until I went to
Project -> Add Reference
And selected System.web. And everything worked link a charm.

It worked for by following process:

Add Reference:

system.net
system.web

also, include the namespace

using system.net
using system.web

Adding a reference to Sysem.Web.Dll did it for me.