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?
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:
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.
System.NullReferenceException: Object reference not set to an instance of an object. at . .?(Stream ) at . .?(String , Assembly ) at Aspose.Pdf.License.SetLicense(String licenseName)
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.
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.
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.
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
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.
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.
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.
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.
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.