Set License Error "object reference not set to an instance of an object

Hi Team,

We have a vb .net application and we get the following error occasionally
“System.NullReferenceException: Object reference not set to an instance of an object.
at .(Stream )
at .(String , Assembly )
at Aspose.Pdf.License.SetLicense(String licenseName)” on any one of our application server.

The code was working fine till last month and now we receive the error and all the Merge PDF process stops. The error goes away after we restart the server.

We are using Aspose.PDF version 17.10. We are also seeing in several thread that the issue is repetitive and never resolved.

Our License for Aspose.PDF will expire soon. Is this issue being fixed in the latest version of aspose.PDF or we have to look for another software to merge the PDF.

Thanks,
Anshul Varun

@Anshul_Varun

Thank you for contacting support.

We have logged a ticket with ID PDFNET-45184 in our issue management system for further investigations and resolution. Being a critical issue, we will schedule it at our earliest. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

Hi Team,

NO NOTIFICATION RECEIVED

Now the error is occurring more, from once in a month now it has occurred twice in past three days on one of our servers. We had to restart the server to fix this issue. **Please suggest when this will be fixed as it is costing us money and makes us look inconsistent in front of our clients. **
Any other way to implement the license for aspose.PDF?
Any Suggestion will be appreciated.

Thanks
Anshul Varun

@Anshul_Varun

We are afraid there is not any other way to apply the license. We are looking into the details and will soon update you with our findings about this issue. Please be patient and spare us little time.

@Anshul_Varun

Thank you for being patient.

We would like to update you that tentative version to include the fix for PDFNET-45184 is Aspose.PDF for .NET 18.9, which will be released within first two weeks of September 2018. We will notify you as soon as the product will be released. We appreciate your patience and comprehension in this regard.

Hi,

The latest version of Aspose.PDF was released two days ago and the “PDFNET-45184” is not mentioned in the release notes. Is the fix for this issue is included in the release or you guys just skipped the issue?
Please advise as this is a big issue and is costing us money.

Thanks
Anshul Varun

@Anshul_Varun

Thank you for getting back to us.

We are afraid PDFNET-45184 has not been resolved yet thus not mentioned in release notes. Actually, we have not been able to reproduce the issue despite repeated attempts owing to random nature of the issue. However, we have taken care of some potential issues that may occur in multi-threaded environment but we are not sure if this relates with your problem. We will continue the investigations and we may share the assembly with debug obfuscation to figure out real source of this issue in your environment. We will get back to you as soon as some significant update will be available in this regard. Please spare us little more time.

Hello,
We’re facing the same issue more than once a day.
Can you share some more details on the problem or assist on a workaround while you are solving the problem?
Regards,
Raimond

@RaimonddeLange

Thank you for contacting support.

Would you please elaborate the issue you are currently facing. It will be helpful for us if you can share a sample application reproducing this issue somehow. Also mention your environment details so that we may address your concerns accordingly.

Hi

I have seen so many open forums for this issue but none of them got any solution.This is a repetitive issue with the software and they have only one thing to say “this is a random issue. we are not able to replicate it”. We have bought the aspose.PDF (last month) and aspose.WORD(yesterday).

Do you people want us to do your job and replicate the issue for you so that you guys can address it ? This is very irresponsible on your end. We are facing very major issues because of this and our business is getting effective.

Thanks,
Anshul Varun

@Anshul_Varun

We apologize for the inconvenience faced. Please note that in order to resolve an issue, it is necessary that issue is reproducible in our environment. Please note that your issue seems environment specific. As shared earlier, we were only able to notice similar issue in multi-threaded environment and investigating it already.

After preparing each build for release purposes, we run final tests upon it to see whether all fixes are working fine or not. The license setting issue seemed not to be fixed in recent release and which is why it is reopened now. However, the issue is expected to be fixed in next upcoming release of the API and we will surely notify you once issue fix is tested and finalized. We greatly appreciate your patience and comprehension in this matter. Please spare us little time.

We are sorry for the inconvenience.

Hello Farhan,

The issue is reproducable with the sample code below.
I have this issue on my development machine (Win2008 R2 Standard SP1 64 bit, 16GB memory, using Visual Studio 2017), but all our environments encounter the problem.

using System;

using System.Threading;

namespace AsposeSetLicenseThreading
{
class Program
{
static void Main(string[] args)
{
// Create a new Console App
// Add NuGet packages Aspose.PDF and Aspose.Imaging and Aspose.Words to Solution
// Add your own Aspose.Total.lic file to Solution
// tested with Aspose v17.11.0 and latest Aspose versions
// Tested on Win2008 R2 Standard SP1 64 bit, 16GB memory, using Visual Studio 2017
try
{
Console.WriteLine(String.Format("{0} - Main thread: START", Thread.CurrentThread.ManagedThreadId));
//for (int i = 0; i < 50; i++)
//{
DoThreading();
//}
}
catch (Exception ex)
{
Console.WriteLine(“Error : " + ex.Message);
Console.WriteLine(“Error : " + ex.StackTrace);
}
finally
{
Console.WriteLine(String.Format(”{0} - Main thread: DONE”, Thread.CurrentThread.ManagedThreadId));
Console.ReadLine(); // Readline, so processing stops and we can see the output
}

    }

    private static void TestSubclassing()
    {
        try
        {
            var class1 = new SubClass1();
            //var withLicense = new SubClassWithAsposeLicense();
            //withLicense = null;
        }
        catch (Exception ex)
        {
            Console.WriteLine(String.Format("{0} - {1}", Thread.CurrentThread.ManagedThreadId, ex.Message));
            Console.WriteLine(ex.StackTrace);
            throw (ex);
        }
    }

    private static void DoThreading()
    {
        int threadCount = 20;
        Thread[] t = new Thread[threadCount];

        for (int i = 0; i < threadCount; i++)
        {
            t[i] = new Thread(new ThreadStart(TestSubclassing));
        }

        // Give time to initialize
        //Thread.Sleep(500);   // Note 07-09: does not matter if there's some time to initialize. Errors occur random with or without initialisation time

        for (int i = 0; i < threadCount; i++)
        {
            t[i].Start();
        }

        for (int i = 0; i < threadCount; i++)
        {
            Console.WriteLine(String.Format("{0} - Main thread: Do some work.", Thread.CurrentThread.ManagedThreadId));
            Thread.Sleep(0);
        }

        for (int i = 0; i < threadCount; i++)
        {
            t[i].Join();
        }
    }


    internal abstract class Base
    {
        protected Base()
        {
            Console.WriteLine(String.Format("{0} - Base: setting license", Thread.CurrentThread.ManagedThreadId));

            //Aspose.Email.License emailLicense = new Aspose.Email.License();
            //emailLicense.SetLicense("Aspose.Total.lic");

            //Aspose.Words.License wordLicense = new Aspose.Words.License();
            //wordLicense.SetLicense("Aspose.Total.lic");

            Console.WriteLine(String.Format("{0} - Base: setting *PDF* license", Thread.CurrentThread.ManagedThreadId));
            Aspose.Pdf.License pdfLicens = new Aspose.Pdf.License();
            pdfLicens.SetLicense("Aspose.Total.lic");

            Console.WriteLine(String.Format("{0} - Base: setting *Imaging* license", Thread.CurrentThread.ManagedThreadId));
            Aspose.Imaging.License imageLicense = new Aspose.Imaging.License();
            imageLicense.SetLicense("Aspose.Total.lic");

            //Aspose.Cells.License excelLicense = new License();
            //excelLicense.SetLicense("Aspose.Total.lic");

            Console.WriteLine(String.Format("{0} - Base: done setting license", Thread.CurrentThread.ManagedThreadId));
        }
    }

    /// <summary>
    /// Subclass without any additional licensing
    /// 
    /// </summary>
    internal class SubClass1 : Base
    {
        public SubClass1()
        {
            Console.WriteLine(String.Format("{0} - SubClass1 CTor", Thread.CurrentThread.ManagedThreadId));
        }

    }

    /// <summary>
    /// Subclass with additional licensing
    /// </summary>
    internal class SubClassWithAsposeLicense : Base
    {
        public SubClassWithAsposeLicense()
        {
            Console.WriteLine(String.Format("{0} - SubClassWithAsposeLicense CTor", Thread.CurrentThread.ManagedThreadId));
            SetLicense();
        }

        private void SetLicense()
        {
            Console.WriteLine(String.Format("{0} - SubClassWithAsposeLicense: setting license", Thread.CurrentThread.ManagedThreadId));
            
            Aspose.Words.License wordLicense = new Aspose.Words.License();
            wordLicense.SetLicense("Aspose.Total.lic");

            Console.WriteLine(String.Format("{0} - SubClassWithAsposeLicense: done setting license", Thread.CurrentThread.ManagedThreadId));
        }
    }
}

}

In addition to my previous reply: the sample code seems to be working using v18.9. Because it’s a big effort to upgrade and test our custom code to v18.9 (and we are facing a production issue!), a workaround or quickfix on v17.11 would be more than welcome. Once the production issue is resolved, we can plan the upgrade in the upcoming weeks.

@RaimonddeLange

Thank you for elaborating it further.

As we had mentioned earlier in this thread that we have taken care of some potential problems which could have resulted in this exception in multi-threading environment, so you are not facing the issue with latest version of the API. Please note, support is provided based on latest available version and enhancement are incorporated in latest versions. We are afraid there may not be a fix or workaround available for previous versions. Please upgrade to Aspose.PDF for .NET 18.9 to avoid the issue.

Hi Farhan, if I understand correctly you’re not supporting a version less than a year old anymore?? And your advice is to upgrade to v18.9 knowing that we have a production issue here?

While waiting for a defintive answer, in the meanwhile we can take a look at upgrading to the newest version.
Can you sum up all the changes in the API from version 17.11 untill 18.9 for every Aspose.Total .Net component? I looked into the release notes, but I didn’t see coding information for every feature, enhancement or bug.
If you can specifically address all broken backwards compatibility changes in the API, big issues and changed method parameters requiring code changes. We don’t want to end up with more issues than we started.

@RaimonddeLange

Please note that any issue which is reported for a previously released version is fixed in next releases, even if it occurs in last month’s release. That is why the latest versions are improved and advanced versions. So, we are afraid any fix may not be incorporated in older versions.

Please consider upgrading to latest version of the API and if you notice any API change. For instance, any class, method or property missing then all such API changes are documented in Release Notes. Addition or removal of API methods and properties is not very frequent so you may not find the API changes for each version of the API.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

any update?

Thanks,
Anshul Varun

1 Like

@Anshul_Varun

There is no update about PDFNET-45184, at the moment. We will let you know as soon as any significant update will be available.

1 Like

Hi Farhan,

Even we are facing the same issue with the license Object reference error. May I know what was the solution you have adopted to resolve the issue.

Your inputs are really appreciated.

Thanks,