We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

System.NullReferenceException SetLicense("Aspose.Pdf.lic");

Dear All,


my webservice application using Aspose.pdf 8.7.0.0
it thrown an exception as below:

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 occurs on the following:

Aspose.Pdf.License lic_pdf = new Aspose.Pdf.License();
lic_pdf.SetLicense(“Aspose.Pdf.lic”); —> Exception occurs here!!!
lic_pdf.Embedded = true;

Could anybody please help?

Thanks a lot in advance

Regards
Win

Hi Win,


Thanks for your inquiry. Please share your license file via email as suggested here, so we will look into it and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

license sent

Hi Win,


Thanks for sharing the license file. I have tested your license and its working fine at my end. It seems it is license implementation issue in your application.

It is suggested to set license in some Application Level event. When you will set the license in application level event/scope, it will remain valid till the lifespan of application.

  • If you are developing an ASP.NET application, you can call License.SetLicense from the Global.asax.cs (Global.asax.vb) file, in the Application_Start protected method. It is called once when the application starts. Do not call License.SetLicense from within Page_Load methods since it means the license will be loaded every time a web page is loaded.
  • If you are developing a Windows Forms or console application, call License.SetLicense in your startup code, before using Aspose.Pdf for .NET classes.
  • If you are developing a class library, you can call License.SetLicense from a static constructor of your class that uses Aspose.Pdf for .NET. The static constructor will execute before an instance of your class is created making sure Aspose.PDF for .NET license is properly set.
  • in case of WCF service, depending upon its hosting:
- if it is custom ServiceHost - then you can set license in service host start event
- if it is IIS - then set license can be called in Global.asax


Please try to set license as per your application structure and share the results.


Best Regards,

Hi thanks.
I tried to put in global.asax snd yes the problem solved but it become Evaluation version (Aspose’s watermark displayed)

Hi there,


Thanks for your inquiry. Please double check that you are using a legitimate DLL version with your license file, as you are entitle to use any DLL version of the product published before your license subscription expiry date.

Please feel free to contact us for any further assistance.

Best Regards,

This problem still occurs!


I put in global.asax and intermittently the Aspose.Pdf evaluation and watermark displayed…

now, I have to call below everytime I want to use Aspose in each method:

Aspose.Pdf.License lic_pdf = new Aspose.Pdf.License();
lic_pdf.SetLicense(“Aspose.Pdf.lic”);
lic_pdf.Embedded = true;

but once I recompile my webservice project then the Aspose.Pdf evaluation and watermark displaying again …then I have to put new Aspose.Pdf license and .dll again and again…

need advise!.. thanks a lot in advance

Hi Winanjaya,


Thanks for sharing the details.

Some of our other customers also faced similar problems when using License as an embedded resource. Please append default namespace of your application with license file name when using license as an embedded resource. For more information, please visit Using as Embedded Resource

[C#]
// Create a PDF license object
Aspose.Pdf.License license = new Aspose.Pdf.License();
// Instantiate license file
license.SetLicense(MergedAPI.Aspose.Total.lic”);
// Set the value to indicate that license will be embedded in the application
license.Embedded = true;

Hello,


it does not work :frowning: please help out of this license problem

=====

Server Error in ‘/’ Application.

Cannot find license ‘MergedAPI.Aspose.Pdf.lic’.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Cannot find license ‘MergedAPI.Aspose.Pdf.lic’.

Source Error:

Line 15:         {
Line 16: // Code that runs on application startup
Line 17: lic_pdf.SetLicense(“MergedAPI.Aspose.Pdf.lic”);
Line 18: lic_pdf.Embedded = true;
Line 19:

Source File: D:\Project\MTI\WebServiceApplication1\Global.asax.cs Line: 17

Stack Trace:

[FileNotFoundException: Cannot find license ‘MergedAPI.Aspose.Pdf.lic’.]
š..œ(String , Assembly , Boolean ) +473
š..˜(String , Assembly ) +119
Aspose.Pdf.License.SetLicense(String licenseName) +86
WebServiceApplication1.Global.Application_Start(Object sender, EventArgs e) in D:\Project\MTI\WebServiceApplication1\Global.asax.cs:17


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248

Hi Winanjaya,


Please note that MergedAPI was default namespace of my earlier project and ensure that you are using correct namespace as per your project. Please take a look over following image.