/// <summary>
        /// Performs license activation using the specified license activator action.
        /// </summary>
        /// <param name="licenseActivator">Encapsulates license activation
        /// implementation.</param>
        /// <param name="username">The user name to be used for license activation.</param>
        /// <param name="password">The password to be used for license activation.</param>
        /// <param name="saveCredentials">Indicates if the specified credentials should
        /// be saved for further reuse.</param>
        private void _ActivateLicense(
            Func <string, string, LicenseInfo> licenseActivator,
            string username,
            string password,
            bool saveCredentials)
        {
            if (LicenseComponent.RequireAuthentication)
            {
                try
                {
                    licenseActivator(username, password); // exception
                }
                catch (CommunicationException commEx)
                {
                    // in case there is a proxy issue
                    if (commEx.ErrorCode == CommunicationError.ProxyAuthenticationRequired)
                    {
                        // try to authorize proxy server
                        _AuthenticateProxyServerAndGetLicense(
                            licenseActivator,
                            username,
                            password,
                            commEx); // exception
                    }
                    else
                    {
                        throw; // just throw the exception further if it is not proxy issue
                    }
                }

                authorizedUserName = username;

                if (saveCredentials)
                {
                    _SaveGA(username, password);
                }
            }
            else
            {
                LicenseComponent.GetLicense();
            }
        }
 public void ActivateLicenseOnStartup()
 {
     _InvokeLicenseActivation(() =>
     {
         if (LicenseComponent.RequireAuthentication)
         {
             // check if we have stored credentials
             NetworkCredential account = _LoadGA();
             if (account != null)
             {
                 // try to activate license using stored credentials
                 ActivateLicense(account.UserName, account.Password, false);
             }
         }
         else
         {
             // credentials are not required (enterprise deployment scenario)
             LicenseComponent.GetLicense();
         }
     });
 }