Website Licensing

Hi, i currently am using a single developer one website license. I have gone through the Licensing Instructions and have succesfully used the license key.

I currently have numerous classes that use Aspose classes and it seems fairly tedious and inefficient to place the license key file in every class. It also leaves room for human error (i.e. somebody forgets to place the license key code).


I was wondering if and how to set the license file once for the entire website. If this is not possible, is there any way to force an error from Aspose Words if the key is not set before it is used, to prevent any human error?

Thanks,

Nitin


You don't need to apply a license from every class that uses Aspose.Words, you only need to do that once for an application that uses Aspose.Words.

You don't have to set license immediately before using Aspose.Words other classes, the best place to do this is somewhere at the beginning or startup of your application. If its an ASP.NET application, you can place the call to SetLicense in the Global.asax file in the application startup handler.

Also, you can include the license file as an embedded resource into your application and pass just the name of the license file without path, such as "Aspose.Words.lic" and SetLicense will find the license in the embedded resources of your application.

It is not possible to apply an Aspose license once for the whole webserver.

Roman,

I have a .net 2005 Web Application running my presentation layer.
But No Aspose Objects are referenced in that end, it is all done in the Business Layer. In order to ensure that the Business Layer loads the License file everytime, i created a Startup class in my buisness layer that is loaded on the Web Application’s Global.asax.

Is this logic correct? If so, does the license file needs to be in the directory of that project to work? It is NOT throwing an error “file not found”, but the license file is not working.

Thanks,

Nitin

I'm not so sure about Business Layer etc. Technically, SetLicense must be called once, in a process (hard to define what's a process in these days though). Basically, when you call SetLicense, some static variables in Aspose.Words.dll are initialized if the license was valid and then the component just works without outputting a watermark. If Aspose.Words.dll gets unloaded from memory at some stage and then loaded again, obviously you need to call SetLicense again, but I'm not sure this ever happens in .NET.

When you call SetLicense and specify file name without path, it tries to find a license in several places as described in wiki and in the API reference.

If the license is not found, it throws. There is a danger that if your app somehwere catches and silences exceptions, you will not notice it. The component continues to work like there is no license, I mean in evaluation mode.

Roman,

Here is an algorithm describing what is happening

class x{
init(Load License File here)
generate(Print Document)
}

x.init();
x.generate();

With what i have above, the output does not work. I have confirmed the license key by saving a document in the init() function, and the output file is licensed and no watermarks appear.



By the "output does not work" I presume you mean the output document has the evaluation watermark and you expect it should not have it. Is that correct?

The only ways you can get evaluation mark in your document are:

1. Not calling Aspose.Words.License.SetLicense before using Aspose.Words.Document.

2. Getting an exception from Aspose.Words.License.SetLicense and silencing it.

3. Calling Aspose.Words.License.SetLicense("") with an empty string. It is the way to switch back to evaluation mode.

4. Opening a document that already has a watermark in it. Aspose.Words does not remove already existing watermarks.