How To: Apply Global Customizations in the Runtime (KB16)

The SLP Services Runtime allows one to control how the runtime interacts with it’s environment programmatically via the use of Global Customizations

Customizable Elements

Persistent Store Support

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 How to: Choose a Persistent Store Mode

Persistent Store Location

When Persistent Store Support is Optional or Mandatory, one can control the license storage location, e.g., within ClickOnce applications, one can redirect to HKCU

Example Code

1. 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 and require one to select -Disable Licensing- in Code Protector
            // args.Customizations.PersistentStoreSupport = PersistentStoreSupport.None;

        }
    }

2. Triggering the registration of the Customization hook

In order for the preceding customization class to be picked up by the SLP Services 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 main >>

3. VB Port of SlpsIntegration code in 1.

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