我想为Aspose.Words dll设置许可证,该许可证部署在azure环境中 .
该方法正在使用一些USQL代码 .
在正在调用的代码后面设置许可证时,看起来它已成功设置,但结果文档(从word文档转换的pdf)仍然有水印 .
可能是使用许可证信息设置的dll不是实际使用的那个?
是否可以在上述场景中设置许可证?
如果可能的话,这样做的正确方法是什么?
如果不可能,有没有办法将"pre-license"后来注册到azure的dll?谢谢 .
Update 1 :用于设置许可证的代码示例:
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 :这是我用来设置许可证的相关代码段,根据下面的注释
USQL:
@test =
SELECT sa.ConfigureLicense() AS License
FROM @t;
OUTPUT @test
TO "Test/LicenseResult.txt"
USING Outputters.Text();
代码背后:
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内容:
“许可证设置成功./21/2018 10:26:23 AM,许可证设置为True”
结果打印输出显示许可证设置正确,但我仍然得到水印,表明正在使用的Aspose DLL未获得许可 .
在此运行中,usql作业在本地运行,而不是在azure上运行 .
2 回答
许可证如何运作?它是一个需要与DLL一起部署的额外文件吗?假设它是一个额外的文件:
您是否尝试将代码部署为具有许可证文件作为附加文件的程序集,然后使用
REFERENCE ASSEMBLY
?或者,如果您想使用后面的代码,请确保包含DEPLOY RESOURCE
所需的额外文件 .找出问题(谢谢@Michael Rys的评论 - 他们真的帮了!):
问题在于我如何注册程序集:
(the wrong way) :我使用的是Visual Studio - >右键单击项目 - >注册程序集,然后在Server Explorer视图中,手动注册Aspose.Words程序集 .
(the right way/the way that worked) :注册我自己的程序集时,将许可文件和Aspose.Words添加为“ Additional Files " (and not "托管依赖项”) - 这样我们确保所有程序集都在datalake商店的同一文件夹中,所以当我们调用
SetLicense()
时将应用于稍后将与我们的代码一起使用的相同Aspose dll .screenshot from Visual Studio