The Runtime allows one to control how the it interacts programmatically with it’s environment via the use of Global Customizations.
Customizable Elements
It is possible to customise the following Runtime elements:
- Persistent Store Mode
- Persistent Store Location
Persistent Store Mode
Control whether persistent license repositories are to be usable within one's application (e.g., None, Optional or Mandatory). Additionally, one may customize the persistence mechanism. See Choose a Persistent Store Mode.
Persistent Store Location
When Persistent Store Mode is Optional or Mandatory, one can control the license storage location, e.g., within ClickOnce applications, one can redirect to HKCU. See ClickOnce//VSTO Application Customization.
Example Code
- Add a SlpServicesIntegration class:
public class SlpServicesIntegration { public const string PermutationShortCode =; // TODO: please insert your permutation short code, e.g.: "c637e" static SlpServicesIntegration() { GlobalCustomizations.Instance.PermutationCustomizationsFor( PermutationShortCode ).Customize += CustomizePermutation; } public static void Initialize() { // the real work is done just once in the static initializer, but something will need to trigger its execution } static void CustomizePermutation( object sender, PermutationCustomizations.CustomizeEventArgs args ) { TODO: apply any customizations desired // EXAMPLE 1: redirect license repository to be stored under HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE // args.Customizations.StoreLocation = StoreLocation.UserProfile; // EXAMPLE 2: Disable data repository - this will disable all licensing actions // It requires one to select "Disable Licensing" in Code Protector // args.Customizations.PersistentStoreSupport = PersistentStoreSupport.None; } }
Equivalent VB Code Imports Slps.Runtime.Customizations Imports Microsoft.Licensing Public Class SlpServicesIntegration Const PermutationShortCode As String = ' TODO: please insert your permutation short code, e.g.: "c637e" Public Shared Sub Initialize() ' the real work is done just once in the static initializer, but something will need to trigger its execution End Sub Shared Sub New() AddHandler GlobalCustomizations.Instance.PermutationCustomizationsFor(PermutationShortCode).Customize, AddressOf Customize End Sub Shared Sub Customize(ByVal sender As Object, ByVal args As PermutationCustomizations.CustomizeEventArgs) TODO: Insert customization code End Sub End Class
- Triggering the registration of the Customization hook
In order for the preceding customization class to be picked up by the Runtime, it is necessary to call it's Initialize method in one's mainline code prior to the execution of any protected code or use of the Runtime to perform license processing. The following example shows how one would do this for a normal desktop application.void Main() { SlpServicesIntegration.Initialize(); < // Rest of mainline code }
Comments
0 comments
Article is closed for comments.