Exception at SetLicense method

Hi,

These are examples of exceptions we’re getting:

Object reference not set to an instance of an
object. Stack: at x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(Stream
xcf18e5243f8d5fd3) at
x22bcffa34b42a390.x220f433da4115056.x7d0214bf69711dd9(String x1c1fc72fe1a3b4ea,
Assembly x5807f920b6fc67c4) at Aspose.Pdf.Kit.License.SetLicense(String
licenseName)
Object reference not set to an instance of an object.
Stack: at Aspose.Pdf.?.?(Stream ?) at Aspose.Pdf.?.?(String ?, Assembly ?) at
Aspose.Pdf.License.SetLicense(String licenseName) 

Hi

Thank you for additional information. Have you tried to set license on Application_Start event in your Web applications, as I suggested earlier? Does the same exception occur with Aspose.Words or only with Aspose.Pdf.Kit and Aspose.Pdf?
Best regards.

We had what appears to be a similar issue. It took us several hours to diagnose. For what its worth, we now we have this code which works well for us.

We call AWord.SetLic(); wherever we need to.

Regards,

Doug

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Threading;

namespace bob
{
    class AWord
    {
        private static bool licensed = false;
        protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        static private ReaderWriterLock _liclock = new ReaderWriterLock();

        public static void SetLic()
        {
            if (!licensed)
                try
                {
                    _liclock.AcquireWriterLock(60000);

                    if (!licensed)
                    {
                        Assembly assembly = Assembly.GetExecutingAssembly();
                        string[] rns = assembly.GetManifestResourceNames();
                        Aspose.Words.License license = new Aspose.Words.License();
                        foreach (string s in rns)

                            if (s.Contains("Aspose.Words.lic"))
                            {
                                using (System.IO.Stream st = assembly.GetManifestResourceStream(s))
                                {

                                    if (st != null && log.IsDebugEnabled)
                                        log.Debug("Setting AW license");
                                    if (st == null && log.IsDebugEnabled)
                                        log.Debug("Setting AW license ITS NULL!!!!");
                                    license.SetLicense(st);
                                }
                                licensed = true;
                            }

                    }
                }
                finally
                {
                    if (_liclock.IsWriterLockHeld)
                        _liclock.ReleaseLock();
                }
        }
    }
}

Hi

Thanks for your inquiry. You should apply the license only once per application domain. Please follow the link to learn when you should apply the license:
https://docs.aspose.com/words/net/licensing/
https://docs.aspose.com/words/net/licensing/
Also, please check the points described in “Licensing” section in FAQ:
https://forum.aspose.com/t/aspose-words-faq/2711
Best regards,

The issues you have found earlier (filed as 7879) have been fixed in this update.

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