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"));
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With