private void BtnGenerate_Click(object sender, RoutedEventArgs e) { try { if (this.PrivateKey.IsAbsent()) { var Location = Display.DialogGetOpenFile("Select Key file...", ".key", "Keys (*.key)|*.key"); if (Location == null) { return; } PrivateKey = General.FileToString(Location.LocalPath); } // IMPORTANT: Document (XML) and Key Code must be equivalent always to avoid mistakes. var LicenseDoc = Licensing.CreateLicenseInfoSignedDocument(this.TxtUser.Text, ((SimpleElement)this.CbxType.SelectedItem).TechName, ((SimpleElement)this.CbxEdition.SelectedItem).TechName, ((SimpleElement)this.CbxMode.SelectedItem).TechName, DateTime.ParseExact(this.TxtExpiration.Text.Trim(), "yyyyMMdd", CultureInfo.InvariantCulture), AppExec.ApplicationName, AppExec.ApplicationVersionMajorNumber, PrivateKey); this.TxtLicenseDocument.Text = LicenseDoc; } catch (Exception Problem) { Display.DialogMessage("Error!", "Cannot load key file or generate license document.\nProblem: " + Problem.Message, EMessageType.Error); } }