Edit this page

Protecting Telerik UI Assemblies

Technical guidelines for protecting Telerik UI for WPF by Progress binaries when redistributed with other applications.

There are a couple of approaches that you can take:

Use the PowerShell Scripts

Telerik UI source code provides two power shell scripts that will allow you to easily apply the modifications needed to protect the Telerik assemblies without the need to open and edit any files. The scrips are located in the Build\BuildInstructions\AssemblyProtection folder of the Telerik UI source code.

The available scripts are:

  • ApplicationNameModifier.ps1: Uncomments the ValidatePassPhrase() method call and changes the ApplicationName in the Core\Controls\Common\AssemblyProtection.cs file with the provided one.

  • ApplicationNameModifier - DPL.ps1: Uncomments the ValidatePassPhrase() method call and changes the ApplicationName in the Documents\Licensing\AssemblyProtection.cs file with the provided one.

Instructions

1. Right click on the needed script and click Run with PowerShell menu item

run script with PowerShell

2. Enter the new ApplicationName when prompted:

change the application name

3. Rebuild the Telerik UI assemblies using one of the approaches explained in the source code build instructions (located in the Build\BuildInstructions folder).

Building Telerik Assemblies from Source Code

Prerequisites

All control assemblies should be built from source code due to modifications applied to the source files. The source code of UI for WPF is distributed separately and is bundled with build instructions. Please, read the source code building instructions beforehand. For brevity this document assumes that the source distribution ZIP file is extracted in C:\TelerikWPFSource

Instructions

1. Open C:\TelerikWPFSource\Core\Controls\Common\AssemblyProtection.cs in a text editor (notepad, Visual Studio, etc.)

2. Uncomment the following line:

#### __Before__


    public static void Validate()
    {
        //Uncomment the following line
        //ValidatePassPhrase();
    }


#### __After__


    public static void Validate()
    {
        //Uncomment the following line
        ValidatePassPhrase();
    }

3. Change the ApplicationName constant to match the name of your application:

#### __Before__


    internal const string ApplicationName = "MyApp";


#### __After__


    internal const string ApplicationName = "Sample Application Name v2.0 (tm)";

4. Save AssemblyProtection.cs and rebuild the suite (described separately in the source code build instructions document).

5. In your application replace the existing references to the Telerik assemblies with the ones built from the source code.

6. If you run the application now you should get an exception with message "This version of Telerik UI for WPF is licensed only for use by Sample Application Name v2.0 (tm)". Note that "Sample Application Name v2.0 (tm)" will be replaced with the value of the ApplicationName constant.

7. In your application resources App.xaml create a string resource with key "Telerik.Windows.Controls.Key" and value equal to the value of the ApplicationName constant from step 3:

Before

<Application 
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    x:Class="...">
</Application>

After

<Application 
      xmlns="http://schemas.microsoft.com/client/2007"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:system="clr-namespace:System;assembly=mscorlib"
      x:Class="...">
        <Application.Resources>
            <system:String x:Key="Telerik.Windows.Controls.Key">Sample Application Name v2.0 (tm)</system:String>
        </Application.Resources>
</Application>

Building Telerik Documents Assemblies from Source Code

The instructions in the previous section explain how to build the Telerik.Windows.Controls assembly and the assemblies depending on it. The UI for WPF suite contains libraries for processing documents which do not depend on Telerik.Windows.Controls.dll.

If you are building the assemblies needed for one of the components depending on Telerik.Windows.Documents.Core, such as the Telerik Document Processing by Progress libraries, you need to execute the following steps as well.

The following instructions are valid for Telerik UI for WPF version Q2 2014 or later.

1. Open C:\TelerikWPFSource\Documents\Licensing\AssemblyProtection.cs in a text editor (notepad, Visual Studio, etc.).

>In versions of the suite prior to R2 2016, the path is **C:\TelerikWPFSource\Documents\Core\Core\Licensing\AssemblyProtection.cs**.

2. Uncomment the following line:

Before

public static bool IsValid()
{
    // Uncomment the following line
    // return ValidatePassPhrase();
    return true;
}

After

public static bool IsValid()
{
    // Uncomment the following line
    return ValidatePassPhrase();
}

3. Execute steps 3-7 from the previous section.

See Also