Free Support Forum - aspose.com

SetLicense & NullPointerException

Hello,

We are using the Aspose.Pdf.Kit library to merge PDF documents together from a windows service. Almost every time we restart the windows service we run into a NullPointerException "Object reference not set to an instance of an object." when calling SetLicense.

The service is running on Windows Server 2003 R2 and is developed on .NET. It kicks off separate threads to handle the business logic and each thread calls a business logic assembly which creates its own instance of the License class and calls the SetLicense() method. Once the service is running and the error has occured it doesn't happen until the service restarts.

This error seems to be related to: <A href="</A></P> <P>I suspect this is happening because of the multiple calls to SetLicense(). What options do i have?</P> <P>Thanks! </P>

Hi Ali,

Thank you very much for considering Aspose.

Can you please try setting the license once in service’s OnStart method? If it still doesn’t work then please share the sample service project, so we could test the issue at our end. Also, send the license file following the instructions given at this link.

We’re looking forward to help you out.
Regards,

Hello Shahzad,

The library is actually called from a BizTalk Server service so I don't have access to the OnStart method.

Regards,

Ali

Hello,

We've changed the logic to leveage a static License class that gets instantiated only once in a Generate method using a singleton-like pattern. We tested to ensure that only 1 instance of License is instantiated and calls the SetLicense method in test and this works.

When we run this in production (Windows Server 2003 R2, 64-Bit) with 8 processes, the first 6 fail and the last 2 succeed. The first 6 fail with a combination of the following errors:

Message: Index was outside the bounds of the array. (2 occurences)

Stack: at System.Collections.ArrayList.Add(Object value)
at x22bcffa34b42a390.x220f433da4115056.xdc195f1c5804967a()
at x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(Stream xcf18e5243f8d5fd3)
at x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(String x1c1fc72fe1a3b4ea, Assembly x5807f920b6fc67c4)
at Aspose.Pdf.Kit.License.SetLicense(String licenseName)

Message: Object reference not set to an instance of an object. (3 occurences)

Stack: at x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(Stream xcf18e5243f8d5fd3)
at x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(String x1c1fc72fe1a3b4ea, Assembly x5807f920b6fc67c4)
at Aspose.Pdf.Kit.License.SetLicense(String licenseName)

Message: Source array was not long enough. Check srcIndex and length, and the array's lower bounds. (1 occurence)

Stack: at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
at System.Collections.ArrayList.set_Capacity(Int32 value)
at System.Collections.ArrayList.EnsureCapacity(Int32 min)
at System.Collections.ArrayList.Add(Object value)
at x22bcffa34b42a390.x220f433da4115056.xdc195f1c5804967a()
at x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(Stream xcf18e5243f8d5fd3)
at x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(String x1c1fc72fe1a3b4ea, Assembly x5807f920b6fc67c4)
at Aspose.Pdf.Kit.License.SetLicense(String licenseName)

Please advise - this is quite critical.

Ali

Hi Ali,

Can you please clear whether the License is being set only once per application? If not, please try to set it once per application, not per process. If it still doesn’t work then please do let us know.

We’re sorry for the inconvenience.
Regards,


Hello,

Yes it is. Perhaps there's an issue with the license file. Do you have an email i could use to send you the file to validate?

Thanks,

Ali

Hi Ali,

You can follow the instructions on this link to send the license file.

Regards,

Hi Ali,

I have tested your license file at my end and found no problem with the license. I’m sure that the problem is caused by the way the component is consumed in the Biztalk server. I’m not quite sure how you’re consuming the component in the Biztalk server, however I would like to suggest that you try to set the license only once at the start of the service.

If you still find the problem then share further details how you’re consuming the component and we’ll try to figure out the cause of this problem.

We’re sorry for the inconvenience.
Regards,