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

Free Support Forum - aspose.com

SetLicense issue

Hi,

I have a strange issue with calling the SetLicense method for Aspose.PDF. The component is used inside an ASP.NET Webservice. I use the following code when my class is initialized (constructor):

Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Total.lic");
license.Embedded = true;

The license file (Aspose.Total) is valid and embedded in the same dll as embedded resource.

I get the following exception, but only on a customer machine (cannot reproduce it on my machine):
---> System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

[4536] bei ?



..?(Stream )

[4536] bei ?



..?(String , Assembly )

[4536] bei Aspose.Pdf.License.SetLicense(String licenseName)


What could influence the SetLicense behavior? Are there any system parameters (.NET Framework version, OS,..) relevant for getting that working?

Best Regards

Andreas


Hi Andreas,


Thanks for contacting support.

Some of the customers experienced similar issues while setting the license and we made some resolutions to license initialization issues in recent release versions. However when using license as an embedded resource, please add application namespace as prefix to license file name in SetLicense(…) method. Please try using the latest release and follow the instructions specified over Using as Embedded Resource

Furthermore, license for Aspose.Pdf can be set
once during application execution cycle and there is no need to recall
license set code. However there is no harm in
calling license initialization code when referencing the license using
string object. But when using Stream object, the problems may occur because the license file will be locked by one instance and other
instance of Stream will try to read/load its contents.

Please
note that Aspose.Pdf for .NET initializes the license when first
instance/object of Aspose.Pdf for .NET is created and its recommended to
place the license initialization code n some static method which is
executed once at that start of application. There is no need to
re-initialize the license in multi-threaded environment when a new
thread is created. The license is valid until the main application
thread is running.

May be you can place the license
initialization code in Main(), Page_Load() or any method which is
executed at the start of application. We are sorry for this
inconvenience.
Hi,

I've followed your suggestions and implemented it as it was described.
Unfortunately it doesn't solve the issue.
I also tried to load the license file from a physical file instead of embedded resource which didn't change anything. I've done that in the constructor of my converter class, and even tried on the static constructor of the class.

Then I moved the code setting the license to my method where I convert PDF using the component (instead of the constructor), and it worked!

Why? I guess the license shouldn't be applied every time a document/page is being converted (which is called very often). Why doesn't it work when calling from within the (static) constructor of my class?

Regards
Andreas

Hi Andreas,


Thanks for sharing the details.

As shared earlier, the license is initialized when first instance of Aspose.Pdf is initialized and its not required to call license initialization on every document conversion routine. However in order for us to replicate this issue in our environment, please share some sample project, so that we can test the scenario in our environment. We are sorry for this inconvenience.