Protecting Telerik assemblies in class library project

6 posts, 0 answers
  1. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 13 May 2014 Link to this post

    Hi 
    I am using the Telerik UI for WPF controls in a class library project that will be loaded into a 3rd party application. I want to protect the Telerik controls but I have no App.XAML file in which to put the Telerik.Windows.Controls.Key entry.

    Is there another way to achieve the same?


    Also, just to clarify, does my project have to be rebuilt using the new references to the protected Telerik assmblies?  


    Thanks
    Craig
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 15 May 2014 Link to this post

    Hello Craig,

    You could add the needed for our protection mechanism Resource with code in the Class Library project like this:

    Application.Current.Resources.Add("Telerik.Windows.Controls.Key", "MyApp");

    Just make sure that it is called before loading the controls.

    As to the other question - yes, the application should be rebuilt after updating the assemblies.

    Hope this helps.

    Regards,
    Yana
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 11 Jun 2015 in reply to Yana Link to this post

    Hi Yana

    Which assembly is Application a member of?

     

    Regards,

    Craig

  5. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 11 Jun 2015 in reply to Craig Link to this post

    I've created a sample WPF application to verify the protection works but it only seems to work if the key string is set in App.XAML.

    I tried the suggested code but the licence message box still appears even though the ApplicationName and key values are the same. 

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Application.Current.Resources.Add("Telerik.Windows.Controls.Key", "MyAppName (tm)");
        }
    }

     

     

  6. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 12 Jun 2015 in reply to Craig Link to this post

    I've discovered the line of code has to be performed before initialisation i.e.

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            Application.Current.Resources.Add("Telerik.Windows.Controls.Key", "MyAppName (tm)");
            InitializeComponent();
        }
    }

     

    This is fine in an purely WPF application but as I mentioned at the beginning, my DLL is loaded within a 3rd party application. How would I achieve the same in that case?

  7. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 16 Jun 2015 in reply to Craig Link to this post

    I now have a solution to this. Since the host is a non-WPF application there is no System.Windows.Application object. One has to be created i.e. 

    if (null == System.Windows.Application.Current)
    {
        new System.Windows.Application { ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown };
    }
    System.Windows..Application.Current.Resources.Add("Telerik.Windows.Controls.Key", "MyApp");

     

    When your application terminates, explicitly call the Shutdown method.

    (Thanks to Balaji at AutoDesk for pointing me in the right direction).

    Craig

Back to Top
UI for WPF is Visual Studio 2017 Ready