分析 Telerik.Windows.Controls 程序集( 程序集说明是 Trial Version)。找到关键代码段,为什么验证这么简单? ,还是这个版本的BUG?

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="RadControlsSilverlightApp1.App"
             xmlns:ms="clr-namespace:System;assembly=mscorlib"
             >
    <Application.Resources>
        <ms:String x:Key="Telerik.Windows.Controls.Key">MyApp</ms:String>
    </Application.Resources>
</Application>

只要在 App.xaml 中定义 “Telerik.Windows.Controls.Key”,就直接绕过了试用版提示窗口。那我将这个试用版的 Telerik silverlight 的程序集.dll文件提取出来打包,以后可以直接用这套 Telerik 控件库了吗!

 

    [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="target")]
    public static void Verify(FrameworkElement target)
    {
        if ((!RadControl.IsInDesignMode && (Application.Current != null)) && (Application.Current.Resources["Telerik.Windows.Controls.Key"] == null))
        {
            VerifyImpl(target);
            AssemblyProtection.Validate();
        }
    }

  

    [Conditional("TRIAL")]
    private static void VerifyImpl(FrameworkElement target)
    {
        if (!messageShown)
        {
            if (RadControl.IsInDesignMode)
            {
                messageShown = true;
            }
            else if (IsSafeHost)
            {
                messageShown = true;
            }
            else
            {
                target.Loaded += new RoutedEventHandler(TelerikLicense.LoadedHandler);
            }
        }
    }

 

    // Properties
    private static bool IsSafeHost
    {
        get
        {
            if (!isSafeHost.HasValue)
            {
                if (!HtmlPage.IsEnabled)
                {
                    isSafeHost = false;
                }
                else
                {
                    string uri = HtmlPage.Document.DocumentUri.OriginalString;
                    isSafeHost = new bool?(((((uri.StartsWith("http://localhost/", StringComparison.OrdinalIgnoreCase) || uri.StartsWith("http://localhost:", StringComparison.OrdinalIgnoreCase)) || (uri.StartsWith("http://www.telerik.com/", StringComparison.OrdinalIgnoreCase) || uri.StartsWith("http://demos.telerik.com/", StringComparison.OrdinalIgnoreCase))) || ((uri.StartsWith("http://minifier.telerik.com/", StringComparison.OrdinalIgnoreCase) || uri.StartsWith("http://demos.telerik.webdev64.telerik.com/", StringComparison.OrdinalIgnoreCase)) || (uri.StartsWith("http://blogs.telerik.com/", StringComparison.OrdinalIgnoreCase) || uri.StartsWith(@"file://C:\", StringComparison.OrdinalIgnoreCase)))) || (((uri.StartsWith(@"file://D:\", StringComparison.OrdinalIgnoreCase) || uri.StartsWith(@"file://E:\", StringComparison.OrdinalIgnoreCase)) || (uri.StartsWith(@"file://F:\", StringComparison.OrdinalIgnoreCase) || uri.StartsWith(@"file://G:\", StringComparison.OrdinalIgnoreCase))) || (uri.StartsWith(@"file://X:\", StringComparison.OrdinalIgnoreCase) || uri.StartsWith(@"file://Y:\", StringComparison.OrdinalIgnoreCase)))) || uri.StartsWith(@"file://Z:\", StringComparison.OrdinalIgnoreCase));
                }
            }
            return isSafeHost.Value;
        }
    }

   

    private static void LoadedHandler(object sender, EventArgs args)
    {
        if (!messageShown)
        {
            ShowTrialMessagePopup();
            messageShown = true;
        }
        (sender as FrameworkElement).Loaded -= new RoutedEventHandler(TelerikLicense.LoadedHandler);
    }

 

        public static void ValidatePassPhrase()
        {
            Application app = Application.Current;
            if (!RadControl.IsInDesignMode)
            {
                if (app.Resources.Contains("Telerik.Windows.Controls.Key"))
                {
                    string appName = app.Resources["Telerik.Windows.Controls.Key"] as string;
                    if ((appName != null) && (appName == "MyApp"))
                    {
                        return;
                    }
                }
                throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "This version of Telerik RadControls for Silverlight is licensed only for use by {0}", new object[] { "MyApp" }));
            }
        }

 

 

官方描述:http://www.telerik.com/help/silverlight/installation-installing-license-limitations.html

The following topic will explain you the main differences between the licenses available for the Telerik Silverlight Controls and the limitations of the Trial License.

Currently there are two types of licenses used for the Telerik RadControls:

  • Developer License
  • Trial License

Collapse imageDeveloper License

Developer licenses come with modified DLLs, which work without license keys. If you have a Developer license for one or more of the Telerik components, you only need to ensure that you are using the developer build when downloading the control(s). These builds have the Dev abbreviation in their file names.

If your application is displaying a license key error, this means that you are using a trial version of the product. Log in to your Client.net account and download the developer build. To update your project, please take a look at the Upgrading the Trial License to a Production License section for step-by-step instructions.

Collapse imageTrial License

The free trial licenses of all Telerik products are fully functional and will work for an unlimited time but with trial error messages (see below) displayed randomly on the page.

Collapse imageTrial Error Messages

The trial licenses will occasionally display the following message on your application:

 Telerik RadControls for Silverlight trial version. Copyright Telerik © 2002-2009. To remove this message, please, purchase a developer version.