public License GetDistributableLicense(string assemblyData) { LicenseClient client = new LicenseClient(_publicKeyXml); try { { LicensePublisherResponse response = client.GetLicense(CultureInfo.CurrentCulture, Product, Version, _licenseEntry.LicenseKey, GetLicenseCategory(LicenseType.Distributable), LicenseEntry.Name, LicenseEntry.Company, LicenseEntry.Email, assemblyData); client.Close(); if (!CheckLicense(response)) { return(null); } else { return(response.License); } } } catch (CommunicationException ex) { LastErrorMessage = ex.Message; client.Abort(); return(null); } }
private static void GetLicense(LicenseCategory licenseCategory) { LicenseClient licenseClient = new LicenseClient(LicenseClient.PublicKeyXmlFromAssembly(Assembly.GetExecutingAssembly())); try { LicensePublisherResponse response = licenseClient.GetLicense( Product, Assembly.GetExecutingAssembly().GetName().Version, s_licenseKeys[(int)licenseCategory], licenseCategory.ToString(), "Test User", "Test Company", "*****@*****.**", MachineLicense.LocalMachineData); License license = response.License; if (license == null) { Console.WriteLine("ERROR: " + response.ErrorMessage); } else { File.WriteAllText(Assembly.GetExecutingAssembly().Location + ".lic", license.SignedString); LicenseManager.Reset(); } licenseClient.Close(); } catch (CommunicationException exception) { Console.WriteLine("EXCEPTION: " + exception.Message); licenseClient.Abort(); } }
private bool CheckLicense(LicensePublisherResponse response) { License license = response.License; if (license == null) { LastErrorMessage = response.ErrorMessage; return(false); } else if (!CheckUpgradeExpirationDate(license)) { LastErrorMessage = Strings.GetMessage(MessageId.InvalidUpgradeExpirationDate); return(false); } else { return(true); } }