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
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
Hi Yana
Which assembly is Application a member of?
Regards,
Craig
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)");
}
}
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?
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