Using Your Doconut License

Instructions for installing and activating your license.

To find out how to use a Doconut license, follow the instructions below for different .NET platforms.

Doconut License Installation

In this section, you will learn how to install and activate your Doconut license across various environments, including .NET Framework, .NET Standard/Core, and .NET 6. Follow the steps provided to ensure seamless integration of your license into your project:

.NET Framework

Automatic License Detection

Doconut can automatically detect licenses if they are placed within the project's bin folder.

Add Manual Default License

If you prefer to add the license manually, the following options are available:

Add License by File Path

This method uses the Viewer.DoconutLicense(string licencePath) overload to add a license by specifying the path to the license file.

csharp
var licensePath = "path/to/your/license.lic";
Viewer.DoconutLicense(licensePath);

Add License by Stream

This method uses the Viewer.DoconutLicense(Stream licenseStream) overload to add a license using a stream.

csharp
using (var licenseStream = new FileStream("path/to/your/license", FileMode.Open))
{
    Viewer.DoconutLicense(licenseStream);
}

Add License by XML Document

This method uses the Viewer.DoconutLicense(XMLDocument licence) overload to add a license using an XML document.

csharp
var xmlDoc = new XmlDocument();
xmlDoc.Load("path/to/your/license.xml");
Viewer.DoconutLicense(xmlDoc);

Add Plugin License by File Path

This method uses the Viewer.SetLicensePlugin(string pathPluginLicence) overload to add a plugin license by specifying the path to the plugin license file.

csharp
var pluginLicensePath = "path/to/your/plugin-license.lic";
new Viewer().DoconutLicense(pluginLicensePath);

Add Plugin License by Stream

This method uses the Viewer.SetLicensePlugin(Stream pluginLicence) overload to add a plugin license using a stream.

csharp
using var pluginLicenseStream = new FileStream("path/to/your/plugin-license.lic", FileMode.Open);
var viewer = new Doconut.Viewer();
viewer.DoconutLicense(pluginLicenseStream);

Add Plugin License by XML Document

This method uses the Viewer.SetLicensePlugin(XMLDocument xmlPluginLicence) overload to add a plugin license using an XML document.

csharp
var viewer = new Viewer();
viewer.DoconutLicense("path/to/your/plugin-license.xml");

.NET Standard/Core and .NET 6 and higher

Automatic License Detection

Doconut can automatically detect licenses if they are placed within the project's wwwroot folder.

To initialize the docViewer with automatic license detection, use the following line:

csharp
using Microsoft.Extensions.DependencyInjection;
var docViewer = app.Services.GetRequiredService<Doconut.Viewer>();

Add Manual Default License

You can manually specify the path to a single default license file when initializing the viewer.

csharp
using System.IO;
var licenseFilePath = Path.Combine(path, "path/to/your/license");
var token = await viewer.OpenDocumentAsync(licenseFilePath, new BaseConfig(), new DocOptions(), ct);

Add License by Stream

This method uses the Viewer.DoconutLicense(Stream licenseStream) overload to add a license using a stream.

csharp
using (var licenseStream = new FileStream("path/to/your/license", FileMode.Open))
{
    var license = new DoconutLicense
    {
        DocBytes = new BinaryReader(licenseStream).ReadBytes((int)licenseStream.Length)
    };
}

Add License by XML Document

This method uses the Viewer.DoconutLicense(XMLDocument licence) overload to add a license using an XML document.

csharp
using System.Xml;
using Doconut.Infrastructure.Licensing;

var xmlDoc = new XmlDocument();
xmlDoc.Load("path/to/your/license.xml");
var license = new DoconutLicense(); // populate properties from xmlDoc as needed

Manual Default Multiple Plugin Licenses

If you need to specify multiple licenses, you can provide a list of file paths to the viewer initialization.

csharp
// Licences are configured via dependency injection; no explicit constructor is required.
var viewer = /* DI‑resolved Viewer instance */ null;

Add Plugin License by Stream

This method uses the Viewer.SetLicensePlugin(Stream pluginLicence) overload to add a plugin license using a stream.

csharp
using var licenseStream = new FileStream("path/to/your/plugin-license.lic", FileMode.Open);
var config = new BaseConfig(); // the license stream is consumed internally by BaseConfig

Add Plugin License by XML Document

This method uses the Viewer.SetLicensePlugin(XMLDocument xmlPluginLicence) overload to add a plugin license using an XML document.

csharp
using System.Xml;
var pluginXmlDoc = new XmlDocument();
pluginXmlDoc.Load("path/to/your/plugin-license.xml");
// License loading is no longer required in Doconut.NETStandard 26.9.0

Protecting Your License File

To safeguard your Doconut license file (.lic), it is essential to follow best practices for file security. Store the license file in a secure directory with restricted access, ensuring that only authorized users or services can read it.

Was this page helpful?