What is the Permutation ID and Permutation Short Code that is mentioned in the technical documentation e.g. in KB articles on installation? Where do I find them and how do I use them?
The Permutation ID is the unique identifier of a permutation and corresponds to the name of the permutation file; on SLP Online portal https://srv.softwarepotential.com/Login.aspx you can see the IDs of the permutations in your account by selecting “Accounts” Tab -> “Manage Permutations” from navigation bar -> “ID” column. The Permutation short code is the first 5 characters of the full Permutation ID and is used when referencing the permutation from application code.
Used with Code Protector each permutation provides a unique, random transformation of the IL of the assembly to be protected. An ISV can have one or more permutations, typically using a different permutation for each product being protected.
When a new permutation is first created (and on each subsequent update to that permutation) the ISV will need to download and install the permutation file in Code Protector. As the Code Protector and Permutation versions must be kept in synch then a new Code Protector will have to be downloaded each time a new version of a permutation is created as a result of an update.
(Please note that when a Permutation is updated on SLP Online the update process is irreversible and the old permutation file is overwritten. We therefore recommend that ISVs save the superseded permutation file locally in case of need to revert to that versions for any reason.).
Download: For a given permutation both the Code Protector and Permutation file can be downloaded from the corresponding links in Permutation record on the “Manage Permutations” page; these two downloads will have the version number.
Install: To install the permutation in Code Protector click “Permutations” tab -> “Install Permutation”. Then select the location where you previously downloaded the permutation file and select Install. Now the permutation is installed locally.
Extract: You will then also need to extract the redistributable DLLs and associated files from the permutation file. To do this, still in the Permutation tab in Code Protector -> “Extract Permutation Runtime Files” -> save Permutation Runtime files locally. Once extracted you need to add references to relevant DLLs in your application source code for licensing purposes e.g. when creating custom installer class as per KB7 etc.
Add References: Add references in your solution to the following three core DLLs (that are always included with your protected assemblies):
Microsoft.Licensing.Permutation_XXXXX_2.0.dll (where XXXXX is the Permutation Short Code)
Microsoft.Licensing.Runtime2.0.dll
Microsoft.Licensing.Utils2.0.dll
Be aware that you must reference the same DLL versions as were used with Code Protector to protect your application.To avoid issues with referencing the wrong DLL versions, we recommend that the required DLLs are maintained in source control.
Using ShortCode: If you have added references to the required DLLs in your application then in code you can reference your permutation by its ShortCode as shown in the following snippets:
- Creating a custom installer class
public class Installer : PermutationInstallerBase
{
public const string STR_MyCompanyPermutationShortId = "90c24";
public Installer()
: base(STR_MyCompanyPermutationShortId)
{
}
......
}
- Creating Runtime instance
private static void DumpAllStoresAndLicenses()
{
using (var runtime = new SLMRuntime(Installer.STR_MyCompanyPermutationShortId))
foreach (ILicenseStore store in runtime.LicenseStores.LocalLicenseStores)
{
Console.WriteLine("Store:- Type: " + store.StoreType + "Id: " + store.StoreId + " State: " + store.State);
foreach (ILicense license in store.InstalledLicenses)
Console.WriteLine(" License:- \"" + license + "\" StoreType: " + license.LicenseStoreType + " StoreId: " + license.LicenseStoreId + " Valid: " + license.IsValid);
}
}