Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load type "System.Web.HttpContext" from assembly "System.Web"

Tags:

c#

.net

System.TypeLoadException: Could not load type 'System.Web.HttpContext' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Xml.Linq;

public class Example : 
{
XDocument doc = XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("~/example.xml"));
}
like image 843
Chris Avatar asked Feb 07 '11 18:02

Chris


1 Answers

Of course, if you are not in a web application, no way you can use the HttpContext.Current !

you can check if System.Web.HttpContext.Current is null or not, it's available only in web pages or web services.

like image 146
Davide Piras Avatar answered Sep 22 '22 23:09

Davide Piras