/// <summary>The method that performs the work, which is run asynchronously by the splash screen.</summary> /// <param name="sender">The sender object.</param> /// <param name="e">Event arguments</param> /// <remarks><para>This method handles the <see cref="LicensingGui.SplashDoWork"/> event.</para></remarks> private void InitializeApplicationSettings(object sender, EventArgs e) { //Load and initialize the license file. m_LastLicenseValidationResult = m_License.InitializeLicense(); //If License is initialized properly, display status. If we created a fresh evaluation, clear the prior error generated from being unable to load an existing license file. if (m_LastLicenseValidationResult && m_License.LastError.ErrorNumber == LicenseError.ERROR_COULD_NOT_LOAD_LICENSE) { m_License.LastError = new LicenseError(LicenseError.ERROR_NONE); } //this.criticalFeatureButton.Enabled = UpdateLicenseStatus(); if (m_Semaphore != null) { m_Semaphore.Close(); m_Semaphore = null; } if (!m_LastLicenseValidationResult && !(m_License.IsWritable) && m_License.ProductOption.OptionType == LicenseProductOption.ProductOptionType.DownloadableLicenseWithTriggerCodeValidation) { //The license is a downloadable license file, and is not supported since the application license is not a WritableLicense... try { //Try to delete the downloadable file. File.Delete(LicenseConfiguration.LicenseFilePath); //Re-initialize the settings and the license objects so none of the information from the downloadable license carries over. m_License = SampleLicense.CreateNewLicense(sampleLicensingGui); sampleLicensingGui.ApplicationLicense = m_License; //Try to load and initialize the license file again. m_LastLicenseValidationResult = m_License.InitializeLicense(); } catch (Exception ex) { statusLabel.Text = "Error: " + ex.Message; } } m_LastLicenseValidationTime = DateTime.UtcNow; }
/// <summary>The method that performs the work, which is run asynchronously by the splash screen.</summary> /// <remarks><para>This method handles the <see cref="LicensingGui.SplashDoWork"/> event.</para></remarks> /// <param name="sender">The sender object.</param> /// <param name="e">Event arguments</param> private void InitializeApplicationSettings(object sender, EventArgs e) { //Load and initialize the license file. m_LastLicenseValidationResult = m_License.InitializeLicense(); //If we created a fresh evaluation, clear the prior error generated from being unable to load an existing license file. if (m_LastLicenseValidationResult && m_License.LastError.ErrorNumber == LicenseError.ERROR_COULD_NOT_LOAD_LICENSE) { m_License.LastError = new LicenseError(LicenseError.ERROR_NONE); } if (!m_LastLicenseValidationResult && !(m_License.IsWritable) && m_License.ProductOption.OptionType == LicenseProductOption.ProductOptionType.DownloadableLicenseWithTriggerCodeValidation) { //The license is a downloadable license file, and is not supported since the application license is not a WritableLicense... string licenseFilePath = (File.Exists(LicenseConfiguration.VolumeLicenseFilePath) ? LicenseConfiguration.VolumeLicenseFilePath : LicenseConfiguration.LicenseFilePath); try { //Try to delete the downloadable file. File.Delete(licenseFilePath); //Re-initialize the settings and the license objects so none of the information from the downloadable license carries over. m_License = SampleLicense.CreateNewLicense(sampleLicensingGui); sampleLicensingGui.ApplicationLicense = m_License; //Try to load and initialize the license file again. m_LastLicenseValidationResult = m_License.InitializeLicense(); } catch (Exception) { //We were unable to delete the downloadable license file. } } m_LastLicenseValidationTime = DateTime.UtcNow; //TODO: If your application has any of its own initialization logic, you can add it here so it runs while the // splash screen is being displayed. }