Free Support Forum - aspose.com

Problems with license code

The issue we are having is that after creating the license object, we are unable to use the SetLicense method to actually register the license with the software. The error we recieve is that the variable name for the license object needs to be declared.


This message was posted using Email2Forum by DannyCooper.

Please share your code that you are using the set the license file. I have already sent your license files to the developers so they can look over them. Here is how you are supposed to set it: http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/HowToUseLicense.html. The developer will help you shortly.

Dear glixa,

Thanks for considering Aspose.Slides for .NET.

I have checked your license file for Aspose.Slides and there is no problem with it. It seems there is some coding problem, probably you are not declaring license object.

Since, you have two license files for two products; so you need to set both of them separately. Every product has its own license class e.g

Aspose.Slides.License

Aspose.PDF.Kit.License

Aspose.Cells.License

It means, for using license of various products, you will have to use complete name of License class to avoid ambiguous names in different namespaces. e.g

So the proper way of setting license would be like this in C#

Aspose.Slides.License slidesLic=new Aspose.Slides.License();

slidesLic.SetLicense(pathToYourSlideLicense);

Aspose.PDF.Kit.License pdfkitLic=new Aspose.PDF.Kit.License();

pdfkitLic.SetLicense(pathToYourPdfKitlLicense);

so on ..

One more thing, you must set the license before using any other product API.

For general programming information, please see products WIKI, for example, the Aspose.Slides.Wiki can be found at this link.

http://www.aspose.com/Wiki/Default.aspx/Aspose.Slides/

Other WIKI(s) can be located from this link.

http://www.aspose.com/Wiki/

I hope, it is helpful.

I have the following 4 lines of code in my vb.net file before any of the product API’s are used.

Dim license As New Aspose.Pdf.Kit.License()
license.SetLicense(“Aspose.Pdf.Kit.lic”)

Dim lic2 As New Aspose.Slides.License()
lic2.SetLicense(“Aspose.Slides.lic”)

I get a “Declaration expected” for the two lines that are actually using the SetLicense method.

Dim lic2 As Aspose.Slides.License = New Aspose.Slides.License()
lic2.SetLicense(“Aspose.Slides.lic”)

and similar for Aspose.Pdf.

I originally had the code like that, however after participating in a live chat with ‘AdeelTaseer’ I changed it to the code I previously posted. I’ve changed the code back to match the example you’ve given and I still get the error.

Please post your code here in the forum.

This is all I am able to post due to the sensitive nature of the rest of the code.

Imports System.IO
Imports System.IO.FileSystemWatcher
Imports System.Diagnostics
Imports System.ServiceProcess
Imports Aspose.Slides
Imports Aspose.Pdf.Kit
Imports System.Drawing



Public Class Service1

'Dim monitorThread As System.Threading.Thread



Private Const RETRYMAXTIME As Integer = 3600000
Private Const RETRYDELAY = 20000

'* licensing Instructions - from the .xml lic file
'* that is received from ASPOSE, uncomment this code,
'* place the lic file in the bin directory of the
'* application and recomplile the program. The application
'* will have to be uninstalled and reinstalled.

'UNCOMMENT NEXT LINE AFTER RECEIVING .LIC LICENSE FROM ASPOSE
Dim license As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License()
license.SetLicense(“Aspose.Pdf.Kit.lic”)

Dim lic2 As Aspose.Slides.License = New Aspose.Slides.License()
lic2.SetLicense(“Aspose.Slides.lic”)



Protected Overrides Sub OnStart(ByVal args() As String)
’ Add code here to start your service. This method should set things
’ in motion so your service can do its work.

'See notes in method
MonitorFolderForPDF()


End Sub

Why licensing code written in the class declaration???
Move it to the OnStart method before any other code.

Not sure why the code was put there, I didn’t write it I’ve just been tasked with maintaining it. Thanks, though, that fixed the issue.