◷ Reading Time: 2 minutes
Loading License
In Version 8, there are three ways of linking and loading the license:
- Using LicenseProvider attribute in assembly
- Using UserLicense.Initialize(YourLicenseProviderType) method call
- Using UserLicense.Key property set (ver 8.0.150+)
LicenseProvider in Assembly
In your assembly set below attribute.
[assembly: LicenseProvider(typeof(FileBasedLicenseProvider))]
Runtime will look for flexrule.license.lic file in the Environment.CurrentDirectory to load the license file automatically.
Using Key Property
Simply set the property of Key in your application as below:
UserLicense.Key = File.ReadAllText("flexrule.license.lic"); // make sure the license file is side by side of the executable
Using Initialize method
Link License
License key can be provided by implementing your own ILicenseProvider type and applying it by calling UserLicense.Initialise(YourLicenseProviderType).
public class MyLicense : ILicenseProvider
{
public string ReadLicense()
{
// make sure the license file is side by side of the executable
return File.ReadAllText("flexrule.license.lic");
}
}
Load License
After you have the type that loads the license, simply use UserLicense.Initialize to initialize your license, on application load.
For example below shows how to initialize the license in a WPF application.
public partial class App : Application
{
public App()
{
UserLicense.Initialize(new MyLicense());
}
}