Karthik Saxena
Karthik Saxena

Reputation: 888

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

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??

Upvotes: 15

Views: 26624

Answers (4)

esenkaya
esenkaya

Reputation: 418

Removed all Microsoft.Aspnet.* and also Microsoft.Web.Infrastructure from References

Upvotes: 1

Adeel Waris
Adeel Waris

Reputation: 1

In the project dependencies, look the one with warnings, remove them. That should do the trick

Upvotes: 0

I believe you have installed packages that are targeting only for Net MVC and therefore has a dependencies on System.Web.HttpContextBase which don't exist in Net Core. To fix this issue you need to find which package you installed don't have support for your Net core and install an alternative

Upvotes: 1

meol
meol

Reputation: 1033

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

Upvotes: 6

Related Questions