Contents

Installing License

This article describes how to configure DotNetBrowser license.

You can obtain an evaluation license and start using your 30-day trial by filling in web form.

If DotNetBrowser finds no license key, EngineFactory.Create() throws NoLicenseException before it starts Chromium. The message lists every place DotNetBrowser checked and what it found there:

No DotNetBrowser license key was found. Checked:
  - EngineOptions.LicenseKey: not set.
  - Embedded resource "dotnetbrowser.license": not found in 42 loaded assemblies.
  - File "dotnetbrowser.license" in C:\MyApp\bin\Release\net8.0: not found.
    A similar file is there: dotnetbrowser.license.txt
To set up the license, see https://links.teamdev.com/dotnetbrowser-license-not-found

A key that DotNetBrowser finds but the license check rejects gives InvalidLicenseException instead. See Common Exceptions for its messages.

To solve it add a proper license key to your project using one of the following ways:

  • Set the license key through the API.
  • Create the dotnetbrowser.license file with your license key and add it as Embedded Resource.
  • Put the dotnetbrowser.license file with your license key in the application directory of your .NET application.

Installing key through the API 

To install your license key use the following API:

C#
VB
IEngine engine = EngineFactory.Create(new EngineOptions.Builder
{
    LicenseKey = "your_license_key"
}.Build());
Dim engine As IEngine = EngineFactory.Create(New EngineOptions.Builder With 
{
    .LicenseKey = "your_license_key"
}.Build())

This approach overrides the license key added as Embedded Resource or copied to the application directory.

Installing key through a license file 

The license file (dotnetbrowser.license) is a simple text file containing the license key. If you have a license key only and need to have the dotnetbrowser.license file, you can create this file in a text editor, such as Notepad or Notepad++, and insert your license key into this file:

Notepad++

Embedded Resource 

In Solution Explorer, right-click your project, select Add > Existing Item… and add dotnetbrowser.license file:

Add Item

In Solution Explorer, right-click dotnetbrowser.license and select Properties. In the Properties panel which opens, select Embedded Resource as Build Action:

Properties

Application directory 

You can copy the dotnetbrowser.license file to the application directory of your .NET application. The process of adding the file is similar to the first approach described above. However, you need to specify the Build Action setting as None and Copy to Output Directory as Copy Always in the Properties section:

Copy to Output Directory

DotNetBrowser looks for the file in AppContext.BaseDirectory, the directory that contains the application assemblies. This is not necessarily the current working directory of the process: an application started from another folder, for example by a shortcut or a service manager, still finds the file.

Which key is used 

DotNetBrowser looks for a key in the following order:

  1. Embedded resources of the assemblies that are loaded when the engine is created. DotNetBrowser reads every resource whose name contains dotnetbrowser.license or DotNetBrowser.license.
  2. The DotNetBrowser.license file, then the dotnetbrowser.license file, in the application directory. On a case-insensitive file system, such as the default one on Windows, these names point to the same file.
  3. The EngineOptions.LicenseKey property.

A key found later replaces a different key found earlier. A key that was already found before is skipped, so it does not replace the key found in between. For example, if the first embedded resource read contains key A, the next one contains key B, and the license file contains key A, DotNetBrowser uses key B.

A key set in EngineOptions.LicenseKey always wins, even when it repeats a key found earlier. A LicenseKey that is empty or contains only whitespace is ignored, and so is an empty license file.

When the license check rejects a key, the InvalidLicenseException message names the source of that key. If that key replaced another one, the message names the source of the replaced key too:

DotNetBrowser license check failed. Reason: Your free 30-day trial period is over.
The key was read from the file C:\MyApp\bin\Release\net8.0\dotnetbrowser.license.
It replaced a key found in the embedded resource "MyApp.dotnetbrowser.license" of MyApp.dll.
Read more at https://links.teamdev.com/dotnetbrowser-trial-period

With the logging level set to Information, Verbose, or All, DotNetBrowser also logs the places it checked and the source of the key it uses, even when the license check succeeds. Neither the messages nor the log contain the key itself.

Key not found or not the one expected 

These are the most common reasons why DotNetBrowser does not use the key you expect:

  • An old license file is left in the output directory. Removing dotnetbrowser.license from the project does not delete the copy in the output directory, such as bin\Release\net8.0. The old file then replaces the key embedded as a resource. Delete the file or rebuild the project from a clean output directory.
  • The file has an extra extension. Notepad saves text files as dotnetbrowser.license.txt, and Windows Explorer hides known extensions by default. The NoLicenseException message lists such files as similar files. Rename the file to dotnetbrowser.license.
  • The file is in a different directory. DotNetBrowser checks only the application directory. The NoLicenseException message shows the path to this directory.
  • The resource is in an assembly that is not loaded yet. DotNetBrowser searches only the assemblies loaded when the engine is created. Embed the license file into the application assembly, or set the key through the API.
  • The file cannot be read. The NoLicenseException message says that the file could not be read and gives the reason, for example, that access is denied. Make sure that the account that runs the application can read the file.
  • EngineOptions.LicenseKey is set to an empty string. This happens, for example, when the key comes from a configuration setting that is missing. A value that contains only whitespace counts as empty too. The NoLicenseException message then says that the value is empty.

The wording of these messages may change between versions. Do not parse them in code.

Adding a license file to the demo application 

To launch DotNetBrowser demo application, add the dotnetbrowser.license file to the directory with DotNetBrowser.Wpf.Demo.exe and DotNetBrowser.WinForms.Demo.exe executables. To do so:

  1. Download DotNetBrowser distribution archive.
  2. Extract the archive into, for example, C:\Downloads\DotNetBrowser-x.x\ directory.
  3. Create the dotnetbrowser.license file in a text editor, such as Notepad or Notepad++. Insert your license key into this file.
  4. Navigate to the Library subfolder and copy/move the license file there:

DotNetBrowser Demo