Exception"The type initializer" while creating PDF using Aspose.PDF (.NET)

Hi. I have a license that allows me to run up to 19.3 version. So I’m using this version.
I have an asp .net core 3.1 web application which is referencing a class library which targets 3.1 as well. In this class library I created some classes and one of them creates a new document in its constructor. I’m referencing Aspose.Pdf in the class library project and I’m trying to open an existing pdf document.

var document = new Document(path);

The path is correct and it is sent via a constructor parameter.

I get an exception whenever i do this:
System.TypeInitializationException: ‘The type initializer for ‘#=zyCshO1gtyn0fwNQKF6J8Y8EydAgY’ threw an exception.’

TypeLoadException: Could not load type ‘System.Web.HttpContext’ from assembly ‘System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.

My first assumption was that the current version of Aspose.pdf does not support .net core which is not true because I looked that up.
The next thing I did was to create 2 new class libraries with the same code, referencing the same Aspose.Pdf dll (19.3) but one targeting .net 4.7 and the other targeting .netstandard 2.0.

Unfortunately I’m still receiving the same error. How is this possible? If the document is created inside the class library this should not be a problem.

Please help.

Upgrading to a new version is not possible because there are no finances to upgrade.

Thanks.

LATER EDIT:
I’m setting the license like this in startup:

Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(“Aspose.Total.lic”);

I’ve downloaded the latest version of Aspose.PDF and I’m getting the same error so I must be doing something wrong but i dont know what.

@dustyenterprise,

Thanks for contacting support.

Can you please share sample project reproducing issue so that we may further investigate to help you out.

I fixed this by removing a nuget package that was causing the problem. Sorry for the late response but it took a while to track down this package. Thank you for your help. Everything works now.

@dustyenterprise,

Its good to know that things started working on your end. Please share feedback with us if there is still an issue.