3

I need to use the HttpUtility in a console app like described in this question UrlEncode through a console application?

The problem is that for some weird reason when I try to add a reference and go to .NET tab, I don't see System.web and also when I go to Recent and chose the System.Web, it adds the reference but with a yellow exclamation mark.

What is wrong, I know that this is a trivial thing...

Community
  • 1
  • 1
Registered User
  • 3,669
  • 11
  • 41
  • 65
  • What language? C#? Which framework version are you targeting? – jeffrey_t_b Jul 06 '12 at 18:04
  • when you place cursor over the yellow mark, what does it say? – Asdfg Jul 06 '12 at 18:05
  • @Asdfg There is no tool-tip, I have no idea why it shows it. – Registered User Jul 06 '12 at 18:10
  • check if the file exists at this location assuming you have selected default installation path: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll. Also right click on your project and see what framework is your project targeting? I assume it will be .Net framework 4.0 but wont hurt to double check. – Asdfg Jul 06 '12 at 18:16
  • @jeffrey_t_b Please convert your comment to an answer so that I can accept. No idea why, but when I created the console app, by default it set the TargetFramework to .NET Framework 4 Client Profile. When I changed it to .NET Framework 4, all got resolved. I have no idea what .NET Framework 4 Client Profile is or why was it the default choice, but I guess that it is a typical Microsoft idiocy that I experience every minute. – Registered User Jul 06 '12 at 18:17
  • possible duplicate of [No System.Web In VS2010](http://stackoverflow.com/questions/2748038/no-system-web-in-vs2010) – Jeffrey Sax Jul 06 '12 at 21:11
  • @JeffreySax How did you find it? I would never found it with a lame title like that. – Registered User Jul 06 '12 at 21:31
  • @RegisteredUser It was listed second in the list of related questions on the right. – Jeffrey Sax Jul 06 '12 at 21:44
  • @JeffreySax Can you please compile a list of all questions that you think are similar to this one so that I can review them. – Registered User Jul 06 '12 at 22:04

2 Answers2

10

Microsoft provides a special "client profile" for the .Net framework, so that application developers can make a smaller/faster deployment package. Although the client profile contains many of the things that simple .Net apps might need (CLR, Windows Forms, etc), oddly enough it doesn't contain the System.Web stuff.

See http://msdn.microsoft.com/en-us/library/cc656912.aspx for more information on what the "client profile" version of the framework contains.

As you discovered, you just need to change the TargetFramework to the normal .Net Framework 4 (in the project properties window), and you will be able to access all of the functions you need.

jeffrey_t_b
  • 1,779
  • 12
  • 18
2

You need to change target Framework Profile: from Client to Full (at VS project properties window).

abatishchev
  • 98,240
  • 88
  • 296
  • 433