Free Support Forum -

Load the aspose license - Object reference not set to an instance of an object


I am working for a client, who has recently purchased a "Site Small Business" license.

We have developed a SOAP based web service, that converts pretty much any document into a PDF.

This web service, is developed using .NET 3.5 framework and used the following Aspose components.

  • Aspose.Cells
  • Aspose.Diagram
  • Aspose.Email
  • Aspose.Pdf
  • Aspose.Slides
  • Aspose.Words

Original with was compiled with the Aspose.Total for .NET API built release on the 11 February 2013.

The license for each API, was set to load by passing in the location to the Aspose.Total.lic for example:

cellsLicense = new Aspose.Cells.License();

However during a heave usage UAT cycle, we noticed that some times the SetLicense call will file for the following API's using the location to the lic file

  • Aspose.Pdf

By raising the runtime error

"Object reference not set to an instance of an object"

After reading a KB article, this was listed as an issue with a work around as loading the license using a resource file.

I therefore upgraded the project to the Aspose.Total API build dated 28th March 2013 and altered all API's to load using a resource file.

This solved the PDF license issue, but the "Object reference not set to an instance of an object", error now occurs for the two API's

  • Aspose.Cells
  • Aspose.Diagram
  • I had to swap the load method to path to the license for these two APIs to fix the error message

    I now have add to load the licenses in different ways depending on the API, which is NOT ideal

    Can you please provide a unified fix in order for me to be able to load the license using one single consistent method



    I would try to give more details if you are linking this issue with Aspose.Cells product.

    We think the issue might not be related to Aspose.Cells product. We also think this exception (e.g. "Object reference not set to an instance of an object" etc.) may occur when multiple threads try to access the license file concurrently during the worst case scenario etc. However, in order to resolve this issue, we would suggest that you avoid concurrent access to the license file (if you are doing this). For example, in order to make sure, you may apply Mutex as shown in the following code:


    Declare Mutex variable:

    Private Shared mutex As New System.Threading.Mutex()

    Apply Mutex:


    Dim lic As New Aspose.Cells.License()


    However, if you still find this issue at your end for your other scenario then please try changing the license setting code as shown below:

    'read the license file into memory stream
    Dim data() As Byte = File.ReadAllBytes("Aspose.Total.lic")
    Dim licenseStream As New MemoryStream(data, 0, data.Length)
    licenseStream.Seek(0, SeekOrigin.Begin)

    'set license
    Dim lic As New Aspose.Cells.License()

    'close memory stream

    Please try this at your end and see if it helps.

    Thank you.