代码之家  ›  专栏  ›  技术社区  ›  Guido Leenders

光栅PDF未正确显示

  •  1
  • Guido Leenders  · 技术社区  · 8 年前

    我们有PDFRasterizer的许可证,但在重新分解代码后,我们在图像中得到了一条斜线:

    Picture with slash

    要激活密钥,C代码将按照中所述配置许可证 Stackoverflow article :

    const string TALL_COMPONENTS_LICENSE_KEY = "SOMETHING-NOT-TO-BE-SHARED";
    TallComponents.Licensing.LicenseCollection.Add("PDFRasterizer.NET 3.0 Client Component Key", TALL_COMPONENTS_LICENSE_KEY);
    

    1 回复  |  直到 8 年前
        1
  •  2
  •   Guido Leenders    8 年前

    从版本控制重构后,似乎AssemblyInfo。cs也必须正确配置。

    AssemblyProduct必须设置为许可证密钥上的产品名称,AssemblyCompany必须设置为您的公司名称。

    代码已扩展为:

    const string TALL_COMPONENTS_LICENSE_KEY = "SOMETHING";
    TallComponents.Licensing.LicenseCollection.Add("PDFRasterizer.NET 3.0 Client Component Key", TALL_COMPONENTS_LICENSE_KEY);
    
    Assembly callingAssembly = Assembly.GetCallingAssembly();
    AssemblyProductAttribute product = callingAssembly.GetCustomAttribute<AssemblyProductAttribute>();
    AssemblyCompanyAttribute company = callingAssembly.GetCustomAttribute<AssemblyCompanyAttribute>();
    
    if (product.Product != "CONSTANT1")
    {
        throw new Exception("The product in the assembly is incorrect.");
    }
    
    if (company.Company != "CONSTANT2")
    {
        throw new Exception("The company in the assembly is incorrect.");
    }
    

    图片不再包含斜杠:

    Picture without slash

    当您不知道预期的公司或产品名称时,您可以登录pdf光栅化器站点并查看许可证的名称。“assigned to”后的文本由公司名称、分隔下划线和预期的装配产品名称值组成。

    总是检查组装产品和公司似乎是明智的,因为在重新配置软件项目时,很容易忘记它们用于许可证检查。当没有明确测试斜杠时,斜杠并不直接可见。这样,许可证配置问题在第一次测试时就直接出现了。