#
Create License Files with .NET Reactor
A license file unlocks your protected application according to the settings you choose. The application checks the license locally, so no internet connection or activation server is required.
You can create licenses manually in the License Manager or automate the process with the LicenseGen.dll SDK. Both approaches use the same .NET Reactor project that you used to protect your application.
#
Offline licensing workflow
The standard license-file workflow is offline. The protected application validates the license locally and does not need to contact .NET Reactor or an activation server.
- Protect the application and keep the saved
.nrprojproject and its master key private. - If the license should be machine-specific, obtain the customer's hardware ID from protected code as described below.
- Create the license on your own system with the License Manager or
LicenseGen.dll. - Deliver the generated license file to the customer.
- Place the license where the protected application expects it, normally next to the protected assembly.
For a license that is not hardware-locked, steps 2 and the hardware-ID exchange are not required.
#
Create a license in the GUI
#
1. Prepare your application
Open your application's assembly in .NET Reactor and configure its protection and Lock Settings. Disable Run Without License if the application must not run without a valid license. To allow a trial instead, see Create a trial version.
Save the .nrproj project and protect the application. Keep this project for license creation: a license must use the same Master Key as the protected application.
#
2. Configure the license
With that project open, switch to the License Manager. Choose the settings for the customer's license, such as an expiration date or a limit on the number of uses. For a permanent license, make sure no unwanted trial or expiration limits remain enabled.
Leave Hardware Lock disabled unless the license should be tied to a particular computer. The optional hardware-locking steps are described below.
#
3. Create and deliver the license file
Click Create License and save the file using the license filename configured for your application. Send it to the customer and have them place it next to the protected assembly.
When the application starts, it automatically uses the matching license and applies its settings. No custom license-import code is needed for this file-based workflow.
#
Create a license using the SDK
For automated license creation, use LicenseGen.dll, available in the Eziriz.Reactor.LicenseGenerator NuGet package.
Add the package to your license-generation project, then load the saved .nrproj project and create the file:
var generator = new LicenseGenerator("MyApp.nrproj");
// This example creates a license without hardware locking.
generator.Hardware_Enabled = false;
generator.CreateLicenseFile("MyApp.license");
Replace the example filenames with your saved project filename and the license filename configured for your application. Deliver the resulting file in the same way as a license created in the GUI.
Run license generation only on your own computer or backend. Do not distribute LicenseGen.dll, the .nrproj project, or the private master key with your application.
#
Optional: lock a license to a computer
First, obtain the customer's hardware ID. Reference License.dll, available in the Eziriz.Reactor.Licensing NuGet package, and read:
string hardwareId = License.Status.GetHardwareID(true, true, true, true);
Read this value from protected code on the customer's computer. An unprotected development build does not return the intended runtime values. If your application cannot start without a license, use a separate protected hardware-ID utility that can run without one.
Have the customer send you the complete ID. In the License Manager, enable Hardware Lock and enter that ID before creating the license.
For SDK generation, replace the Hardware_Enabled = false line with the following before calling CreateLicenseFile:
generator.Hardware_Enabled = true;
generator.HardwareID = "CUSTOMER_HARDWARE_ID";
Replace CUSTOMER_HARDWARE_ID with the ID received from the customer. The resulting license is valid only on the matching computer.
#
Test the result
Test with your protected application, not just an unprotected build in the IDE. Check that a valid license is accepted and that the application behaves as intended without one. For hardware-locked or time-limited licenses, also check that the corresponding restriction is enforced.
#
If a license is not accepted
Check these items before generating a replacement license:
- Matching project and master key: Create the license from the saved
.nrprojproject used to protect the application. A license created with a different master key cannot unlock that protected build. - Correct filename and location: Use the license filename configured for the application and place the file where the protected application expects it, normally beside the protected assembly.
- Hardware ID: For a hardware-locked license, verify that the complete hardware ID was collected on the target computer from protected code and copied without changes. Regenerate the license if the machine or relevant hardware identity changed.
- License restrictions: Check expiration dates, number-of-uses limits, evaluation settings, and other license-file locks in the License Manager.
- Protected build: Reproduce the problem with the protected application.
License.dllreports its intended runtime values only after protection.
If the checks above are correct, recreate the license from the original saved project and test it with a clean copy of the protected output. Problems activating the .NET Reactor product itself are separate; see Activation Troubleshooting.
#
Related topics
License File Settings · License.dll examples · Create a trial version