Can not find System.Web in add reference. RRS feed

  • Question


    I am try to use the method in System.Web.HttpUtility.UrlEncode but intellisense only shows three classes under System.Web. 

    After searching online I found that I need to add a reference to System.Web.dll because I am making a windows application.

    I have looked at this question which is exactly the same thing as mine but that solution is not working. http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/053edd7e-b4c2-4602-98fe-f4e3274c81be

    In the screen shot posted in the solution, System.Web is selected but when I go to add reference I can't find System.Web 





    So went under browse tab and added a reference to 

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web

    but as you can see in the picture, System.Web is showing with a yellow warning (without a tooltip) and It has still not resolved the problem. I am still unable to reference System.Web.HttpUtility. Do I need to add anything in the code to gain access to the reference? I added "Using System.Web" but thats only to save typing (if it was working :P)

    I am using Microsoft Visual C# 2010 Express.

    Thursday, May 27, 2010 2:55 AM

All replies

  • Seems to me this happens because you have targeted the windows application to .net framework 4.0

    But that's not an excuse.

    For time being can you just try creating a Windows Forms Application by selecting framework 3.5 and add the reference to System.Web.

    Meanwhile let me do further investigation of why its not showing in the add reference tab of 4.0 project.

    [MVP Visual C#]
    Dot Net Goodies
    Don't hate the hacker, hate the code
    Thursday, May 27, 2010 5:22 AM
  • Ok got the issue.

    This is because, by default the project created in Framework 4.0 is defaulted to the profile.

    Open the project properties and you can see it as shown below.

    We can change this profile to .Net Framework 4.0 as shown below.

    Once you have done this, you can go and add the reference to System.Web

    Hope this helps!!!


    [MVP Visual C#]
    Dot Net Goodies
    Don't hate the hacker, hate the code
    • Proposed as answer by Xiao Zhang Monday, August 16, 2010 7:06 PM
    Thursday, May 27, 2010 5:48 AM
  • Thanks for taking the time to reply. But I am having trouble implementing your solution. When I change the "Target framework" from ".NET Framework 4 Client Profile" to ".NET Framework 4" I am presented with this:



    When I click "Yes" on the dialog box, the program crashes. 

    I am getting that error every time I try to change the target framework. I have tried restarting the program, restarting the computer, creating a new project and trying to change the framework before I add any code but it still crashes. 

    This seems like it may just be a problem with my install. Should I try to reinstall Microsoft Visual C# 2010 Express?

    I only needed to use the static urlencode method, which I could write myself; but, if possible, I would like to resolve this issue as it is likely to come up again later in the project (I can't rewrite the whole .NET library hehe)


    Thursday, May 27, 2010 5:54 PM
  • Hi,

    Have you tried reinstalling Microsoft Visual C# 2010 Express? Did this cause the problem?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, June 2, 2010 3:19 AM
  • I got the same problem. Seems like the list of assemblies is not ordered by name. Try change the sort order and have a look again.
    Wednesday, June 16, 2010 4:46 PM
  • Perhaps the problem could be in that in Visual Studio C# Express Edition you don't have all the framework but only the C# windows applications relevant dlls usable. Probably the System.Web part of the framework is usable only when you install the Web Developer Visual Studio Express Edition so to allow you to make an ASPX website. This limitation should be due to the fact that otherwise the free express edition would have the same power of a full (and at a cost) Visual Studio 2010 pro edition.


    Wednesday, June 16, 2010 6:03 PM
  • Hi,


    I have encountered the same issue, I'm running Visual Studio 2010 Ultimate so it is not isolated to Express. Lowering the framwork version is not an option for me since I require parts from 4.0. 

    Have you found any solution to the issue?


    Kind regards,


    Friday, June 18, 2010 11:49 AM
  • Ok I gave a deeper look at the problem.
    In my VS 2010 Ultimate also the framework 4.0 does not reference System.Web (and a lot of similar .net 2.0 dlls). So I solved the problem in the following manner:

    Add a new reference by choosing the tab "Browse...". Dig into the C:\windows\microsoft .net\framework\v4.0.30319\ directory and choose System.Web.dll from there. This is the official repository of all .net dlls in your environment. By clicking ok you add it to your project and can start using it.


    Friday, June 18, 2010 1:25 PM
  • Changing .Net Framework 4 Client Profile to .Net Framework 4 works for me! Thanks.
    Monday, August 16, 2010 7:06 PM
  • It's OK!
    Sunday, November 28, 2010 1:34 PM
  • I am having this same problem, so I found the System.Web.dll file you mentioned and added it that way.  It shows up in my references of the project properties now.  It is checked.  However, it still does not recognize the function.  Intellisense does not recognize it, and when I build my project, I get the error

    'HttpServerUtility' is not a member of 'Web'.  Here is how it is being called:

    myString = System.Web.HttpServerUtility.HtmlEncode(myString)

    When I look at the class view for the project, I do not see System.Web listed under references, even though it does show in the references of the project properties.  I am using Visual Studio 2010 Ultimate, and my project type is an Outlook Add-In.  I have never had this kind of thing happen before, so I am really at a loss.  Any help would be greatly appreciated.

    Wednesday, April 18, 2012 4:33 PM
  • OK, after doing a search for the function name in the object browser, I found it in many other libraries.  I finally got it to work by scrapping System.Web and instead using System.Net.WebUtility.  Tested and working.
    Wednesday, April 18, 2012 5:17 PM
  • Thanx frnd it work for me......

    Rahul Lawand The Beginner,

    Sunday, November 29, 2015 7:47 AM