We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Object reference error when setting Aspose.Pdf.License.SetLicense

We are facing object reference error randomly when executing the Aspose.Pdf.License.SetLicense code. We are using Aspose.Pdf file version is

Below is the code snippet we have used in our static class.

Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense("Aspose.Total.lic"); //Exact line.

The Aspose.Pdf.License SetLicense is initialized under individual static method and it is invoked by the static constructor of the same class.

Once the object reference error is thrown, its gets sorted out only after resetting the IIS (Even after initializing the object again, the error is keep repeating until we reset IIS).

We are already calling this license code in static constructor only. So what can be done to avoid these type of exceptions as we cannot reset IIS everytime when we get this error in production.

Request your expertise advice to sort out this issue.

Hello Senthil,

Thanks for contacting support.

In case of an
ASP.NET application, you can call License.SetLicense() method from the
Global.asax.cs file, in
the Application_Start() protected method. It is called once when
the application starts. Do not call License.SetLicense() from within Page_Load() methods, since it means that the license will be loaded every time a web page is loaded.

Senthil B:
We are using Aspose.Pdf file version is

I am afraid that you are using quite old version of the API, whereas we always recommend to use latest version as it contains all fixes and enhancements. Please download Aspose.Pdf for .NET 17.6 from our website, and in case you still face any issue, please share a sample project with your license file. This way we can test the scenario in our environment and address it accordingly.

PS: Please follow the instructions given over “How to Send License File”, to send the license.