SetLicence: System.NullReferenceException: Object reference not set to an instance of an object

Hi guys,

Setting the licence file sometimes gives me this error, why is that?

Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(@"Aspose.Pdf.lic"); <---- ERROR

Error:

System.NullReferenceException: Object reference not set to an instance of an object.
at . .?(Stream )
at .
.?(String , Assembly )
at Aspose.Pdf.License.SetLicense(String licenseName)

While retrying it again, just with the same file, the same code, it works correctly, why?

Hi Ken,

Please check the following documentation links for setting Embedded License in your .NET application.

Using as Embedded resource

If you still face the issue, I would suggest you to test your license by loading license from file path as mentioned in below link.

Using File or Stream object

If you still face any problem, please send your license file to us and we will check the issue and get back to you. Kindly follow the steps mentioned in the below link to send us the license file:

http://www.aspose.com/corporate/purchase/faqs/send-license-to-aspose-staff.aspx

We apologize for your inconvenience.

Thanks & Regards,

Hi Ken,

Thanks for using our products.

Ken van Riel:
We are loading the license file form file path as mentioned in the second link. I'll send you the licence file but i don't think that that is the problem. About nine out of ten calls to create an PDF the file is created succesfully. While retrying an errored call (with just the same information and binary) the second time it is succesfully processed.

I totally agree with you, if the resultant PDF document successfully generated nine times out of ten, then no need to share License file. Can you please share the exact error message you are facing, this might help us to figure out the issue.

We apologize for your inconvenience.

Thanks & Regards,

This is the error message:

System.NullReferenceException: Object reference not set to an instance of an object.
at . .?(Stream )
at .
.?(String , Assembly )
at Aspose.Pdf.License.SetLicense(String licenseName)

How can we get a better error message?

We are also having a similar issue. We upgraded about a month ago now. This never happened until the recent upgrade.


We simply load the license file with:
Dim license As aspose.pdf.license = New aspose.pdf.license()
license.SetLicense(“aspose.pdf.lic”)

On SetLicense, we receive the error:

Inner: System.NullReferenceException: Object reference not set to an instance of an object. at .‰.(Stream ) at .‰.(String , Assembly ) at Aspose.Pdf.License.SetLicense(String licenseName)


It seems that the license file is getting locked up. It will work 98% of the time and then this happens causing every page that accesses the license to throw this error. The only way to resolve it is for us to recycle the application pool.


Hi,

Thank you for reporting this issue to us. For rectification, I logged this problem with ID: PDFNEWNET-33459 in our Issue Tracking System. Our development team will further look into the details of this issue and will keep you updated via this forum thread on the status of correction.

We apologize for your inconvenience.

Thanks & Regards,

Ken van Riel:
This is the error message:

System.NullReferenceException: Object reference not set to an instance of an object.
at �. .?(Stream )
at �.
.?(String , Assembly )
at Aspose.Pdf.License.SetLicense(String licenseName)

How can we get a better error message?

Hi Ken,

Thanks for sharing the details. Can you please share which version of Aspose.Pdf for .NET you are using and also please share some details regarding your working environment. In fact we haven't noticed such issue in our environment while using Aspose.Pdf for .NET 6.8.0. We are really sorry for your inconvenience.

nbtb:
We are also having a similar issue. We upgraded about a month ago now. This never happened until the recent upgrade.

We simply load the license file with:
Dim license As aspose.pdf.license = New aspose.pdf.license()
license.SetLicense(“aspose.pdf.lic”)

On SetLicense, we receive the error:

Inner: System.NullReferenceException: Object reference not set to an instance of an object. at .‰.(Stream ) at .‰.(String , Assembly ) at Aspose.Pdf.License.SetLicense(String licenseName)


It seems that the license file is getting locked up. It will work 98% of the time and then this happens causing every page that accesses the license to throw this error. The only way to resolve it is for us to recycle the application pool.

Hi John,

Can you please confirm the product version that you are using ? Also please note that if you are using license file as an embedded resource, please following the instructions specified over Using as Embedded resource

We are really sorry for your inconvenience.

Hi,

Adding more to Nayyer's comments, kindly share the application as well with environment detail because as per findings of our development team, this issue can be related to environment/application. Without reproduce the issue every time, its very difficult for us to provide a solution. However, we would appreciate if you can use the provided code snippet in different location and check if it fits your need.

We apologize for your inconvenience.

Thanks & Regards,

We are currently using version 6.7.0.0 of Aspose.Pdf for .Net. I will upgrade to 6.8 and see if I continue to have the same issue.


Our project runs with the .Net 3.5 Framework.

Hopefully version 6.8 fixes our issue.

Thanks,
Jonathan

We are using an older version 4.2.0.0 and experienced this same random error with Aspose.PDF.Kit (which I now understand is one product).

This is on a box that has been stable for over a year. We’ve never seen this error. We recycled the app pool and it did seem to clear up.

We do use this as an embedded resource. .net 3.5.

Was this issue ever resolved?

Hi,


Thanks for using our products.

I have tested the scenario using Aspose.Pdf for .NET 6.9.0 where I have used created an application in VisualStudio 2011 Professional running over Windows Server 2008 R2 X64Bit SP-1 and I have set the Target platform of my application as .NET Framework 3.5. During my testing, I have included the license file as an embedding resource and have used the following code to initialize the license and I am unable to notice any problem. Can you please try using the latest release version and see if it resolves your problem. We are sorry for your inconvenience.

[C#]

// Instantiate license object
Aspose.Pdf.License lic = new Aspose.Pdf.License();
// set the license file
lic.SetLicense(“Aspose.Total.Product.Family.lic”);
// included the liense file as an
embedded resource
lic.Embedded = true;

We are also intermittently noticing this issue in our production environment.

We implemented the fix suggested in this thread of making the license an embedded resource, but it has not solved the problem. As others have suggested, recycling the apppool gets things working again. We are using .NET 3.5 with Aspose 6.6.

Given the difficulty to reproduce this intermittent error, I am not sure I can provide a code sample in this instance. However, I hope this information helps you to diagnose the problem.

Hi Mark,

Thanks for contacting support.

In one of my earlier posts, I have asked the customer to include license file as an embedded resource so that license file is not skipped, but if you are placing the license file along with your solution, you may consider referencing it via String or Stream object. However, concerning to the issue which you have stated, please ensure that you are initializing the license once at the beginning of application and you are not setting the license on every new request. And in case you are using some multi-threaded application, please initialize the license only once i.e. may be in some static method which is called at the begining of application/solution.

Also please note that the current latest release version is Aspose.Pdf for .NET 7.1.0 and there has been many changes since the release of v6.6.0. May be you can consider using the new release version to see, if it can resolve your problem. We are sorry for your inconvenience.

Hi Nayyer, thanks for the additional information. We are indeed setting the license once per request. We’ll have another look.

Thanks again.
Mark

Edit: we added the license instantiation to Application_Start in global.asax, and are confident this will resolve the issue, thanks again.

Hi Mark,


I am glad to hear that your problem is resolved. Please continue using our product and in the event of any further query, please feel free to contact.

The issues you have found earlier (filed as PDFNEWNET-33459) have been fixed in Aspose.Pdf for .NET 7.4.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)

This problem has continued to get worse for us. It shows that the problem from issue (PDFNEWNET-33459) was resolved and we would happily upgrade if we knew for sure that we wouldn’t have any more issues with this. As it is now, we have to manually go in and recycle our application pool 3-8 times per day or any page of ours that tries to access the license file ends up throwing an exception.


How do we find out about upgrading and what happens if we upgrade and continue to have the same problem? Since this problem only happens on our production site when we are getting thousands of visitors accessing the pages at the same time, we haven’t been able to replicate it in a test environment.

Thanks,
Jonathan

Hi Jonathan,


Sorry for the inconvenience faced. The reported issue was resolved as customer revisited his license implementation logic.

“Edit: we added the license instantiation to Application_Start in global.asax, and are confident this will resolve the issue, thanks again.”

Could you please double check your license implementation? you only need to set the license once per application domain and in case of Web applications to set license on Application_Start event of application.

Please also make sure that you are using the latest version of Aspose.Pdf as over the time we have made enormous enhancements and fixes in API. Please consider documentation while upgrading from older versions.

Please feel free to contact us for any further assistance.

Best Regards,