Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I reference System.Web.Extensions in a Console application?

The assembly is not in the list in the Add Reference... dialog. When I find it manually and add it, it has a small exclamation point over it and I can't seem to refer to it in code.

I tried it on 2 different copies of VS2010 with same results.

like image 632
AngryHacker Avatar asked Sep 20 '11 05:09

AngryHacker


3 Answers

Change Target Framework from Client profile to the full framework and you will be able to add it.

like image 98
manojlds Avatar answered Oct 19 '22 00:10

manojlds


Console applications, by default, target the ".NET Framework xx Client Profile" that doesn't include the web assemblies. Change the target framework to ".NET Framework xx" in Project -> Properties -> Application.

like image 3
amit_g Avatar answered Oct 19 '22 00:10

amit_g


It is most likely because of the framework version that your project is targeting.

If you are targeting .NET 4.0 Client Profile, web assemblies are not included. Change the project to target 4.0 and you should be good.

like image 3
Jay Avatar answered Oct 19 '22 01:10

Jay