Barcode License throwing null exception

When I call this:

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

I get this:

System.ApplicationException: Exception while creating Barcode System.ApplicationException: Exception while creating Barcode Image System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.BarCode.x220f433da4115056.x7d0214bf69711dd9(Stream xcf18e5243f8d5fd3)
at Aspose.BarCode.x220f433da4115056.x7d0214bf69711dd9(String x1c1fc72fe1a3b4ea, Assembly x5807f920b6fc67c4)
at Aspose.BarCode.License.SetLicense(String licenseName)

The program was working this morning but stopped suddenly around 9AM. I checked the .lic file, and it appears fine. It is still working on all the other servers, the development environment and on local machines. So why it is failing on just our production server is troublesome. I searched google for the error and it returned this URL, but I believe the post was deleted.

https://forum.aspose.com/t/31230

I have a Aspose.BarCode for .NET Developer Enterprise Subscription which does not expire until November 9th. The Aspose.BarCode.dll version is 2008.06.27, a little old, I know, but we haven’t had a chance yet to test and deploy the newest versions of the assembly.

Hi,

Thanks for considering Aspose.

Could you please provide some more details about the scenario in which SetLicense() is failing e.g. .NET framework and OS version (32/64 bit).

The post <A href="https://forum.aspose.com/t/31230</A> was made private by the customer, so its not visible by other users. But, in this post, he was generating barcodes in threads and SetLicense was called in the thread, which was creating problems. When SetLicence() was moved to Init()/Load() method, the problem was resolved. Could you please tell us where the SetLicense() method is being called. It is supposed to be called once per application/process.</P>

That is definitely the problem then. I actually have Aspose in a remoting service on a server called by a .NET desktop application… so it isn’t part of a page lifecycle and the thread it is running in could extend beyond a single call. I’ll try putting Aspose into a static property so that it only needs to set the license once regardless of how long the thread is around. Thanks for the tip!