Exception in License.SetLicense Method

Getting a null reference exception in Aspose.Words.License.setLicense(). The application within which this is occurring has been running for many days without issue, so it would seem to be coming as a result of a degradation.
FYI, the call to this method is made within a class constructor of an object that gets created for each request to an IIS-hosted SOAP service within the code executes. Might there be an issue with multiple calls to this method during the course of an application’s execution? Any other thoughts on this?
EXCEPTION TEXT:

Error: Exception occured creating document CSU_GEN_510038268_2392_2011-11-10_14-17-58-203.docxMessage: Object reference not set to an instance of an object.. Stacktrace: at x28925c9b27b37a46.x220f433da4115056.x7d0214bf69711dd9(Stream xcf18e5243f8d5fd3)
at x28925c9b27b37a46.x220f433da4115056.x7d0214bf69711dd9(String x1c1fc72fe1a3b4ea, Assembly x5807f920b6fc67c4)
at Aspose.Words.License.SetLicense(String licenseName)
at DocBuilder.Service.generateDocument(DocumentData documentData) in C: \dev\ DocBuilder\ Service.asmx.cs: line 41

CODE CALLING METHOD:

public DocumentGenerator()
{
    Aspose.Words.License license = new Aspose.Words.License();
    license.SetLicense("Aspose.Total.lic");
}

Hi
Thanks for your inquiry. The license only needs to be set once per application domain. You need to set the license before using any other Aspose.Words classes. Calling License.SetLicense multiple times is not harmful, but simply wastes processor time.
Please see the following link to learn where to apply the license:
https://docs.aspose.com/words/net/licensing/
Best regards,

I take the point that the setLicense method need only be called once during the run of the application. This was a bit of pre-existing code that needs to be cleaned up. You did say, though, that making these multiple calls to the method are not harmful. What then is the cause of the library incurrng an exception?

Hi
Thanks for your inquiry. This is quite interesting question. But unfortunately, it is difficult to answer it because we cannot reproduce the problem. If it is possible, it would be great if you create a simple application that will allow us to reproduce the problem.
Best regards,

It has not been possible to reproduce the problem in a test program. This seems to be a case of a state degradation. The method is being called from a single location in the code with a string literal being provided for the single parameter.

From the supplied stack trace, is it possible to identify the line of code causing the problem?

Thanks,
Bob

Hi Bob,
Thanks for your request. Unfortunately it is not possible to identify the line of code where the exception occurs using the supplied stack trace.
Have you tried changing your code so the setting license was executed only one per application domain, i.e. on application start event or in static constructor? Just as Andrey suggested.
Best regards,

At the first opportunity in our release cycle I will change the code as suggested. Also, and more probably the cause where, it was discovered that a change had been made in IIS to combine NET 1.x and NET 2.x applications in the same process space. This has been changed and I have not since seen the problem recur. …hopefully this will be the end of it.

Thanks,
Bob

Hi Bob,
Please let us know if you need more assistance, we are always glad to help you.
Best regards,