This is a migrated thread and some comments may be shown as answers.

Protecting Telerik assemblies in class library project

5 Answers 166 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 13 May 2014, 01:27 PM
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

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 15 May 2014, 09:26 AM
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.
 
0
Craig
Top achievements
Rank 1
answered on 11 Jun 2015, 02:02 PM

Hi Yana

Which assembly is Application a member of?

 

Regards,

Craig

0
Craig
Top achievements
Rank 1
answered on 11 Jun 2015, 03:06 PM

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)");
    }
}

 

 

0
Craig
Top achievements
Rank 1
answered on 12 Jun 2015, 07:30 AM

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?

0
Craig
Top achievements
Rank 1
answered on 16 Jun 2015, 09:13 AM

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

Tags
General Discussions
Asked by
Craig
Top achievements
Rank 1
Answers by
Yana
Telerik team
Craig
Top achievements
Rank 1
Share this question
or