System.TypeLoadException: 'Could not load type 'System.Web.HttpContextBase' from assembly 'System.Web,

12,575

the class exists in other namespace so make sure you're using Microsoft.AspNetCore.Mvc and not the .NET framework version.

Share:
12,575

Related videos on Youtube

Karthik Saxena
Author by

Karthik Saxena

By Day: Listen to lot of things and explore new possibilities. By Night: Think and try to solve real world problem through programming. For Fun: Listen to Music and learn more and more about the digital world.

Updated on June 13, 2022

Comments

  • Karthik Saxena
    Karthik Saxena almost 2 years

    Whenever I try to load the Chart using System.Web.Helpers namespace in Asp.net Core I get this Exception.

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

    Please See the image

    new System.Web.Helpers.Chart(width: 800, height: 200).AddTitle("My Chart").AddSeries(chartType: "column", 
               xValue: new[] { _context.DemoTable.Select(o => o.Month) },
               yValues: new[] { _context.DemoTable.Select(o => o.AutomationPercentage) }
              ).Write("png");
    

    What am I doing wrong here??

    • Nirman
      Nirman about 6 years
      System.Web.HttpContextBase is part of System.Web assembly. .NET core by default does not add reference of this DLL, and it is also not preferred to do so. I think System.Web.Helpers is .NET Framework library and not .NET Core
    • Karthik Saxena
      Karthik Saxena about 6 years
      Thanks for the reply.. Can you please tell me which library do I need to add so as to get this work.
  • Ross Gustafson
    Ross Gustafson over 4 years
    I get this error while trying to test .NET Framework code from a xUnit .NET Core unit test. What do I need to add to my .NET core project to make this work?