I'd like to set the license for Aspose.Words dll, that is deployed on azure environment.
The dll is being used with some USQL code behind methods.
When setting the license in the code behind that is being called, it looks like it's being set successfully, but the resulted document (a pdf converted from word document) still has the watermark on it.
Probably the dll that was set with the license information is not the one that was actually being used?
Is it possible to set the license in the scenario described above?
If it's possible, what is the proper way to do that?
If it's not possible, is there a way to "pre-license" the dll that will later be registered into azure?
thanks.
Update 1: code sample for setting the license:
static public string ConfigureLicense()
{
var asposeWordLicense = new License();
try
{
asposeWordLicense.SetLicense("Aspose.Words.lic");
return $"License set successfully. {DateTime.Now.ToString()}";
}
catch (Exception e)
{
return "\nThere was an error setting the license: " + e.Message;
}
}
Update 2: here is the relevant code snippets that I used to set the license, as per the comments below
USQL:
@test =
SELECT sa.ConfigureLicense() AS License
FROM @t;
OUTPUT @test
TO "Test/LicenseResult.txt"
USING Outputters.Text();
Code Behind:
public static string ConfigureLicense()
{
var asposeWordLicense = new License();
try
{
MemoryStream stream = new MemoryStream(File.ReadAllBytes(@"Aspose.Words.lic"));
asposeWordLicense.SetLicense(stream);
return $"License set successfully. {DateTime.Now.ToString()} , License set to {asposeWordLicense.IsLicensed}";
}
catch (Exception e)
{
return "\nThere was an error setting the license: " + e.Message;
}
}
LicenseResult.txt content:
"License set successfully. 3/21/2018 10:26:23 AM , License set to True"
The result printout shows the license was set correctly, but I'm still getting the watermark which indicates the Aspose dll that is being used is NOT licensed.
In this run, the usql job was run locally, not on azure.
Figured out the problem (thank you @Michael Rys for your comments - they really helped!):
The issue was around how I was registering the assemblies:
(the wrong way): I was using Visual Studio -> right click on the project -> register assembly and then on the Server Explorer view, manually registering Aspose.Words assembly.
(the right way/the way that worked):
when registering my own assembly, add the license file and Aspose.Words as "Additional Files" (and not "Managed Dependencies") - that way we ensure that all the assemblies are in the same folder on datalake store, so when we're calling SetLicense()
it will be applied to the same Aspose dll that will later be used with our code behind.
screenshot from Visual Studio