许可

评估 Aspose.HTML for .NET

您可以轻松下载 Aspose.HTML for .NET 评估版。请注意,评估版本与购买版本相同。当您添加几行代码来应用许可证时,它就变成了许可版本。

评估版(未指定许可证)提供完整的产品功能,但也有一些限制:

如果您想测试 Aspose.HTML for .NET,而不受评估版的限制,您也可以申请 30 天的临时许可证。请参阅 如何获得临时许可证?

申请许可证

购买后,您需要应用许可证文件或将许可证文件作为嵌入式资源。Aspose.HTML for .NET 提供了几种应用许可证的方法。本节将介绍如何应用许可证。

注意: 使用完全限定的许可证类名称。如果您在使用 Aspose.HTML for .NET 的同时还使用了任何其他 Aspose for .NET 组件,则需要为许可证指定完整的命名空间,如 Aspose.Html.LicenseAspose.Html.Metered。每个 Aspose 产品在自己的命名空间中都有一个 License 类。例如,Aspose.HTML 有 Aspose.Html.License 类,Aspose.SVG 有 Aspose.Svg.License 类。使用完全限定的类名可以避免混淆哪个许可证适用于哪个产品。

从磁盘或数据流应用许可证

应用许可证的最简单方法是将许可证文件放在与 Aspose.HTML.dll 文件相同的文件夹中,并只指定文件名而不指定路径。

1   // Initialize a license object
2   Aspose.Html.License htmlLicense = new Aspose.Html.License();
3
4   // Apply the license using the file name
5   htmlLicense.SetLicense("Aspose.HTML.lic");

也可以从许可证文件流中申请许可证。

1   // Initialize a license object
2   Aspose.Html.License htmlLicense = new Aspose.Html.License();
3
4   // Open a license file stream
5   using (var stream = new System.IO.FileStream("Aspose.HTML.lic", System.IO.FileMode.Open))
6   {
7      // Apply the license using the stream
8      htmlLicense.SetLicense(stream);
9   }

使用单例

最好的方法是在代码的关键点使用 Singleton 通过懒惰初始化实现许可证。下面展示了如何通过在项目中添加几行代码来实现这一点。

 1   internal class LicenseSingleton
 2   {
 3      private static LicenseSingleton _instance = new LicenseSingleton();
 4      private LicenseSingleton()
 5      {
 6            // init the license
 7            (new Aspose.Html.License()).SetLicense(@"F:\aspose.html.net\testdata\license\Aspose.HTML.NET.lic");
 8      }
 9
10      public static void SetLicense()
11      {
12            LicenseSingleton local = _instance;
13      }
14   }
15
16   static void Main(string[] args)
17   {
18      //lazy initialization before using the library
19      LicenseSingleton.SetLicense();
20   }

将许可证作为嵌入式资源应用

将许可证与应用程序打包的另一种巧妙方法是将其作为嵌入式资源包含在调用 Aspose.HTML for .NET 的程序集中。

要将许可证文件作为嵌入式资源,请执行以下步骤:

  1. 在 Visual Studio 中,右键单击 .lic 文件并从打开的菜单中选择 Add -> Existing Item…,将该文件包含到项目中。
  2. 在解决方案资源管理器中选择该文件,并在 Properties 窗口中将 Build Action to Embedded resource
  3. 在代码中,调用 SetLicense,只传递资源文件的简短名称。
1   // Initialize a license object
2   Aspose.Html.License htmlLicense = new Aspose.Html.License();
3
4   // Apply the license using the embedded resource name
5   htmlLicense.SetLicense("Aspose.HTML.lic");

请注意,资源是嵌入到程序集中的,无需修改。如果将文本文件作为嵌入资源添加到应用程序中,并用记事本打开生成的 EXE,就会看到所添加文本文件的确切内容。因此,当使用许可证文件作为嵌入式资源时,任何人都可以用简单的文本编辑器打开 EXE 文件,查看/提取嵌入式许可证的内容。

申请计费许可证

计量许可 – 是一种新的许可机制,与现有的许可方法一起使用。那些希望根据 API 功能使用情况收费的客户可以使用计量许可。Aspose.HTML 允许开发人员应用计量密钥。有关详细信息,请参阅 使用计量许可 一文。

完成获取此类许可证的所有必要步骤后,您将收到密钥,而不是许可证文件。可以使用专门为此引入的 Metered 类应用这种计量密钥。下面的代码片段演示了如何使用私钥和公钥应用计量许可证:

1   // Initialize a metered object
2   Aspose.Html.Metered metered = new Aspose.Html.Metered();
3
4   // Apply the metered license using the public and private keys
5   metered.SetMeteredKey("*****", "*****");

通常,在应用程序启动时应用一次计量许可证即可。但是,如果计量许可机制在 24 小时内无法与 Aspose 服务器通信,Aspose.HTML 将退出许可模式并切换到评估模式。为避免出现这种情况,应定期检查许可证状态。如果 Aspose.HTML 转为评估模式,请重新申请计量许可。

请注意,为了正确使用计费许可证,您必须有稳定的互联网连接,因为计费机制需要与我们的服务持续互动才能正确计算。更多信息,请参阅 计费许可证常见问题 部分。

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.