Set

License.Set method (1 of 2)

Sets the license from a license file.

public static void Set(string licensePath)
parameterdescription
licensePathThe path to the license file (.lic extension). Can be either a metered license file (XML with PublicKey/PrivateKey elements) or a standard license file.

Exceptions

exceptioncondition
FileNotFoundExceptionThrown when the license file is not found at the specified path.
InvalidDataExceptionThrown when the license file format is invalid or corrupted.

Remarks

This method supports two types of license files:

  1. Metered license files - XML files with the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<License>
    <PublicKey>your_public_key_here</PublicKey>
    <PrivateKey>your_private_key_here</PrivateKey>
</License>
  1. Standard license files - Standard GroupDocs license files with Data and Signature elements.

Metered licenses require an active internet connection for validation.

Examples

// Set license from file in application directory
License.Set("GroupDocs.Conversion.LowCode.lic");

// Set license from absolute path
License.Set(@"C:\Licenses\GroupDocs.Conversion.LowCode.lic");

// Set license from relative path
License.Set("../licenses/GroupDocs.Conversion.LowCode.lic");

See Also


License.Set method (2 of 2)

Sets the license using public and private keys.

public static void Set(string publicKey, string privateKey)
parameterdescription
publicKeyThe public key provided by GroupDocs for your license.
privateKeyThe private key provided by GroupDocs for your license.

Remarks

This method requires an active internet connection for license validation.

Keys should be kept secure and not exposed in source code. Consider using environment variables or secure configuration.

Examples

// Load keys from environment variables (recommended)
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");
License.Set(publicKey, privateKey);

// Load keys from configuration (alternative)
var publicKey = ConfigurationManager.AppSettings["GroupDocsPublicKey"];
var privateKey = ConfigurationManager.AppSettings["GroupDocsPrivateKey"];
License.Set(publicKey, privateKey);

See Also