Shelf Life Check
A Shelf Life Check is a type of Check that detects if an application is being run after a certain date. This gives the application a shelf life - a limited period of time for which it can be run.
Shelf Life Checks are particularly useful for beta or evaluation software. If the user attempts to run the application beyond the expiration date, a Shelf Life Check can detect this and react by sending incident telemetry, notifying the application, and causing the application to exit. In other words, a Shelf Life Check detects and reacts to unauthorized use of your application based on the current date.
Configuring Shelf Life Checks
To have Dotfuscator inject Shelf Life Checks into your application, you must first obtain a Shelf Life Activation Key from PreEmptive Solutions.
Once you have an Activation Key, enable code injection.
Then, configure the Checks via the user interface or by annotating your source code with
Both of these methods allow you to specify various properties that determine how the Check operates; for a full listing, see the
ShelfLifeCheckAttribute section of the Check Attributes page.
A Shelf Life Activation Key is a data file that is required to inject Shelf Life Checks. To obtain an Activation Key, contact PreEmptive Solutions.
Once issued, you must specify the path to the Activation Key in each Shelf Life Check's ActivationKeyFile property. We recommend keeping a copy of the Activation Key on each build machine.
The Activation Key is only needed when Dotfuscator processes the application. The application does not need to access the Activation Key at runtime, so it should not be distributed outside of the development organization.
A Shelf Life Token is a file containing information about an application's shelf life, such as the expiration date. Rather than embedding the expiration information directly into the application, Dotfuscator generates a Token containing this information. At runtime, the Shelf Life Check uses the Token to determine if the application has expired.
In Community Edition, when Dotfuscator injects a Shelf Life Check, it automatically generates a Token based on the Check's ExpirationDate property, then embeds the Token in the application for the Check to use at runtime.
Note: In Professional Edition, you can instead generate the Token manually, and store it however you please, assuming the application can provide it to the Shelf Life Check at runtime. For instance, if you provide the Token to the application using a web service, you can change the Token without redistributing the application, allowing for expiration date extensions and per-user expiration dates.
Professional Edition also allows you to sign Tokens with public / private key pairs, to ensure Tokens used at runtime are authentic.
Each Shelf Life Token has an associated expiration date. When a Shelf Life Check using the Token runs, it compares the expiration date to the current time (using an algorithm more complex than just checking the system time). If the expiration date is in the past, the Check determines the application to be expired. What happens as a result of the application being expired depends on the application notification properties.
The expiration date for a Shelf Life Check is specified by the Check's ExpirationDate property.
Note: Dotfuscator Professional Edition also allows a Token to set a warning date, to notify the user when the expiration draws near.
Dates for a Shelf Life Tokens are configured as strings, in one of two formats:
An absolute date, specified in the form
A date relative to the date Dotfuscator generated the Token, specified as an integer indicating the number of days.
For instance, if Dotfuscator generates the Token on August 1, 2017, and the application should expire on August 31, 2017, the expiration date can be written as either
Shelf Life Checks can send telemetry when the application is expired. For more information, see the Check Telemetry page.
Having a Shelf Life Check notify the application code is a feature exclusive to Professional Edition.
Shelf Life Checks do not support Check Actions. A configuration equivalent to the use of the Exit Action can be done by setting the ExpirationNotificationSinkElement property of the Check to DefaultAction.
When a Shelf Life Check with this configuration detects expired application usage, it will cause the application to exit immediately with exit code 0.
Supported Application Types
Dotfuscator can inject Shelf Life Checks into all .NET assemblies except for the following:
- Managed C++ assemblies containing native and managed code
- Multi-module assemblies
- Silverlight assemblies
- Windows Phone assemblies
- WinRT assemblies
- Xamarin assemblies
- Unity assemblies
- .NET Core assemblies
To test how the Shelf Life Checks injected into your application react to expired application usage, the simplest method is to temporarily configure the Checks with the expiration dates in the past. Be sure to exercise all locations of your Shelf Life Checks. Once you have tested that the application acts as it should when it is expired, you will need to change the dates back to their intended values before building the project for distribution.