使用

时间:2018-03-20 17:26:10

标签: azure u-sql aspose.words

我想为在Asure环境中部署的Aspose.Words dll设置许可证 dll正在使用一些USQL代码背后的方法 在正在调用的代码后面设置许可证时,看起来它已成功设置,但结果文档(从word文档转换的pdf)仍然有水印。

使用许可证信息设置的dll可能不是实际使用的那个?

是否可以在上述方案中设置许可证?
如果可能的话,这样做的正确方法是什么? 如果不可能,有没有办法“预先许可”后来注册到azure的dll? 感谢。

更新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;
    }
}

更新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内容:

  

“许可证设置成功。3/21/2018 10:26:23 AM,许可证设置为True”

结果打印输出显示许可证设置正确,但我仍然收到水印,表明正在使用的Aspose dll未获得许可。
在此运行中,usql作业在本地运行,而不是在azure上运行。

2 个答案:

答案 0 :(得分:0)

许可证如何运作?它是一个需要与DLL一起部署的额外文件吗?假设它是一个额外的文件:

您是否尝试将代码部署为使用许可文件作为附加文件的程序集,然后使用REFERENCE ASSEMBLY?或者,如果您想使用代码,请确保使用DEPLOY RESOURCE包含额外需要的文件。

答案 1 :(得分:0)

想出问题(谢谢@Michael Rys的评论 - 他们真的帮了!):
问题在于我如何注册程序集:

(错误的方式):我使用的是Visual Studio - >右键单击项目 - >注册程序集然后在Server Explorer视图上,手动注册Aspose.Words程序集。

(正确的方式/工作方式): 注册我自己的程序集时,将许可文件和Aspose.Words添加为“附加文件”(而不是“托管依赖项”) - 这样我们就可以确保所有程序集都在datalake上的同一文件夹中存储,所以当我们调用SetLicense()时,它将应用于相同的Aspose dll,稍后将与我们的代码一起使用。
screenshot from Visual Studio