public AboutBox() { InitializeComponent(); foreach (Assembly s in AppDomain.CurrentDomain.GetAssemblies()) { string[] lvsi = new string[3]; lvsi[0] = s.GetName().Name; lvsi[1] = s.GetName().FullName; lvsi[2] = s.GetName().Version.ToString(); ListViewItem lvi = new ListViewItem(lvsi, 0); this.ListOfAssemblies.Items.Add(lvi); } AssemblyCopyrightAttribute objCopyright = AssemblyCopyrightAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute; AssemblyDescriptionAttribute objDescription = AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute; AssemblyCompanyAttribute objCompany = AssemblyCompanyAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute; AssemblyTrademarkAttribute objTrademark = AssemblyTrademarkAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTrademarkAttribute)) as AssemblyTrademarkAttribute; AssemblyProductAttribute objProduct = AssemblyProductAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)) as AssemblyProductAttribute; AssemblyTitleAttribute objTitle = AssemblyTitleAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute; GuidAttribute objGuid = GuidAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(GuidAttribute)) as GuidAttribute; DebuggableAttribute objDebuggable = DebuggableAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DebuggableAttribute)) as DebuggableAttribute; CLSCompliantAttribute objCLSCompliant = CLSCompliantAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(CLSCompliantAttribute)) as CLSCompliantAttribute; AppName.Text = objProduct.Product; BigTitle.Text = objTitle.Title; ProdVer.Text = QuestDesignerMain.Version; AppDesc.Text = objDescription.Description; CopyrightLabel.Text = objCopyright.Copyright; SerialNo.Text = objGuid.Value; Company.Text = objCompany.Company; }
public FrmLogin(FrmStart _frmstart) { InitializeComponent(); try { this.frmStart = _frmstart; this.tbPwd.Region = new Region(GetRoundRectPath(new RectangleF(0, 0, this.tbPwd.Width, this.tbPwd.Height), 5f)); this.tbUserName.Region = new Region(GetRoundRectPath(new RectangleF(0, 0, this.tbUserName.Width, this.tbUserName.Height), 5f)); this.iniSysInfo(false); this.tbUserName.Text = string.Empty; this.tbPwd.Text = string.Empty; this.ActiveControl = this.tbUserName; this.tbUserName.Focus(); Assembly assembly = Assembly.GetExecutingAssembly(); //this.labelEdition.Text = assembly.FullName; // 获取程序集元数据 AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute) AssemblyCopyrightAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)); AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)); } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", "FrmLogin--->FrmLogin-->Error:" + ex.ToString(), LogEnum.ExceptionLog); } }
private void ShowVersion() { AssemblyCompanyAttribute objCompany = (AssemblyCompanyAttribute) AssemblyCompanyAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute)); AssemblyDescriptionAttribute objDescription = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)); AssemblyProductAttribute objProduct = (AssemblyProductAttribute) AssemblyProductAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)); AssemblyTitleAttribute objTitle = (AssemblyTitleAttribute) AssemblyTitleAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)); /* * AssemblyVersionAttribute objVersion = (AssemblyVersionAttribute) * AssemblyVersionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), * typeof(AssemblyVersionAttribute)); */ StringBuilder sb = new StringBuilder(); sb.Append("Product: "); sb.AppendLine(objProduct.Product); sb.Append("Title: "); sb.AppendLine(objTitle.Title); sb.Append("Company: "); sb.AppendLine(objCompany.Company); sb.Append("Description: "); sb.AppendLine(objDescription.Description); sb.Append("Version: "); sb.AppendLine(Assembly.GetExecutingAssembly().GetName().Version.ToString()); this.AboutText.Text = sb.ToString(); }
//===================================================================== /// <summary> /// Set the version and assembly info on load /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void AboutDlg_Load(object sender, EventArgs e) { // Get assembly information not available from the application object Assembly asm = Assembly.GetEntryAssembly(); AssemblyTitleAttribute title = (AssemblyTitleAttribute) AssemblyTitleAttribute.GetCustomAttribute(asm, typeof(AssemblyTitleAttribute)); AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute) AssemblyCopyrightAttribute.GetCustomAttribute(asm, typeof(AssemblyCopyrightAttribute)); AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute)); // Set the labels lblName.Text = title.Title; lblDescription.Text = desc.Description; lblVersion.Text = "Version: " + Application.ProductVersion; lblCopyright.Text = copyright.Copyright; // Display components used by this assembly sorted by name foreach (AssemblyName an in asm.GetReferencedAssemblies()) { ListViewItem lvi = lvComponents.Items.Add(an.Name); lvi.SubItems.Add(an.Version.ToString()); } lvComponents.Sorting = SortOrder.Ascending; lvComponents.Sort(); // Set e-mail link lnkHelp.Links[0].LinkData = "mailto:" + lnkHelp.Text + "?Subject=EWSoftware CalendarBrowser Demo"; }
/// <summary>Initializes an instance of FrmAbout.</summary> public FrmAbout() { InitializeComponent(); StartEventProcessing(); AssemblyCopyrightAttribute copyright; AssemblyDescriptionAttribute description; // Display the Verifier information. lblVerifierNameVersion.Text = Verifier.GetFullTitle(true); copyright = (AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)); description = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)); lblVerifierDescription.Text = description.Description; lblVerifierCopyright.Text = "Copyright " + copyright.Copyright; // Display the Classless.Hasher information. lblHasherNameVersion.Text = Verifier.GetFullTitleHasher(); copyright = (AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute(Assembly.GetAssembly(typeof(Classless.Hasher.MD5)), typeof(AssemblyCopyrightAttribute)); lblHasherCopyright.Text = "Copyright " + copyright.Copyright; // Display the .NET information. lblNETNameVersion.Text = Verifier.GetFullTitleNET(); // Display the OS information. lblOSNameVersion.Text = Classless.Utilities.OperatingSystem.Name + " v" + Classless.Utilities.OperatingSystem.Version.ToString(2) + " (" + Classless.Utilities.OperatingSystem.Version.Build.ToString() + ")"; }
public AboutDialog() { this.Build(); AssemblyTitleAttribute title = (AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute( System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)); //AssemblyVersionAttribute version = (AssemblyVersionAttribute)AssemblyVersionAttribute.GetCustomAttribute( // System.Reflection.Assembly.GetExecutingAssembly() , typeof(AssemblyVersionAttribute)); label2.Markup = "<span size='x-large'>" + title.Title + "</span>"; // + " " + version.Version; //AssemblyCompanyAttribute company = (AssemblyCompanyAttribute)AssemblyCompanyAttribute.GetCustomAttribute( // System.Reflection.Assembly.GetExecutingAssembly() , typeof(AssemblyCompanyAttribute)); AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute( System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)); AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute( System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)); label3.Text = description.Description; label4.Text = copyright.Copyright; }
static App() { Assembly asm = Assembly.GetCallingAssembly(); Name = asm.GetName().Name; Version = asm.GetName().Version.ToString(3); Banner = $"{Name} v{Version}"; Type type = typeof(AssemblyDescriptionAttribute); if (AssemblyDescriptionAttribute.IsDefined(asm, type)) { AssemblyDescriptionAttribute a = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(asm, type); Banner += " - " + a.Description; } type = typeof(AssemblyCopyrightAttribute); if (AssemblyCopyrightAttribute.IsDefined(asm, type)) { AssemblyCopyrightAttribute a = (AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute(asm, type); Banner += Environment.NewLine + a.Copyright.Replace("©", "(c)"); } }
private void readAssembly() { Assembly me = Assembly.GetExecutingAssembly(); this.name = me.GetName().Name + " v" + me.GetName().Version; Type type = typeof(CustomAssemblyVariable); if (CustomAssemblyVariable.IsDefined(me, type)) { string releaseType = ((CustomAssemblyVariable)CustomAssemblyVariable.GetCustomAttribute( me, type )).value; if (releaseType != "Release") { this.name += " - " + releaseType + " version!"; } } type = typeof(AssemblyDescriptionAttribute); if (AssemblyDescriptionAttribute.IsDefined(me, type)) { this.desc = ((AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(me, type)).Description; } else { this.desc = "N/A"; } }
public static string LoadAssemblyDescription(Assembly quickMonAssembly) { AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute( quickMonAssembly, typeof(AssemblyDescriptionAttribute)); return(desc.Description); }
public static string LoadAssemblyDescription(string assemblyFilePath) { Assembly quickAsshehe = Assembly.LoadFile(assemblyFilePath); AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute( quickAsshehe, typeof(AssemblyDescriptionAttribute)); return(desc.Description); }
private void SetupControl() { Assembly asm = _CallingAssembly; string AppTitle = ((AssemblyProductAttribute)AssemblyProductAttribute.GetCustomAttribute(asm, typeof(AssemblyProductAttribute))).Product; AppTitle += " v" + asm.GetName().Version.ToString(2); lblAppName.Text = AppTitle; lblAppTitle.Text = ((AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute))).Description; lblCopyright.Text = ((AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute(asm, typeof(AssemblyCopyrightAttribute))).Copyright; StringBuilder AuthorBuilder = new StringBuilder(); if (_Authors == null) { AuthorBuilder.Append("Authors: Anonymous"); } else { if (_Authors.Length == 1) { AuthorBuilder.Append("Author: "); } else { AuthorBuilder.Append("Authors: "); } bool First = true; foreach (string Auth in _Authors) { if (!First) { AuthorBuilder.Append(", "); } AuthorBuilder.Append(Auth); First = false; } } lblAuthors.Text = AuthorBuilder.ToString(); //Visual Studio requires the namespace to be applied to the resource name, otherwise it can't find it. Stream LicenseStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LICENSE"); if (LicenseStream == null) { LicenseStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Absinthe.Gui.LICENSE"); } StreamReader str = new StreamReader(LicenseStream); txtLicense.Text = str.ReadToEnd(); txtLicense.Select(0, 0); }
/* * companyname: * Describes the name of the company. If no companyname is supplied Application.CompanyName will be used. * * productname: * Describes the name of the product. If no productname is supplied Application.ProductName will be used. * * applicationdescription: * * executable: * */ public FileAssociationManager(string companyname, string productname, string applicationdescription, string executable) { if (string.IsNullOrEmpty(companyname)) { companyname = Application.CompanyName; } if (string.IsNullOrEmpty(productname)) { productname = Application.ProductName; } if (string.IsNullOrEmpty(applicationdescription)) { Assembly exeasm = Assembly.GetExecutingAssembly(); AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(exeasm, typeof(AssemblyDescriptionAttribute)); applicationdescription = desc.Description; if (string.IsNullOrEmpty(applicationdescription)) { applicationdescription = Application.ProductName; } } if (string.IsNullOrEmpty(executable)) { executable = Application.ExecutablePath; } // *** if (string.IsNullOrEmpty(companyname)) { throw new Exception("Company name cannot be null or empty!"); } if (string.IsNullOrEmpty(productname)) { throw new Exception("Product name cannot be null or empty!"); } // *** _companyName = companyname; _productName = productname; _applicationDescription = applicationdescription; _executablePath = executable; if (IsDefaultProgramsAvailable()) { _applicationRegistration = (IApplicationAssociationRegistration) new ApplicationAssociationRegistration(); } }
private void PopulateAlgorithmChooseControl(List <IFrequentPatternMining> _miningAlgorithms) { foreach (IFrequentPatternMining detector in _miningAlgorithms) { AssemblyDescriptionAttribute desc; AssemblyTitleAttribute title; desc = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(detector.GetType().Assembly, typeof(AssemblyDescriptionAttribute)); title = (AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute(detector.GetType().Assembly, typeof(AssemblyTitleAttribute)); string str = string.Format("{0}, {1}, {2}", detector.GetType().FullName, title, desc); combo_algoritmo.Items.Add(str); } }
public static string GetAssemblyDescription(Assembly asm) { if (asm == null) { return(string.Empty); } if (AssemblyDescriptionAttribute.IsDefined(asm, typeof(AssemblyDescriptionAttribute))) { AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute)); return(description.Description); } return(string.Empty); }
private int get_current_version(ref string productName) { Assembly assembly = Assembly.GetExecutingAssembly(); // 获取程序集元数据 AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute) AssemblyCopyrightAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)); AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)); productName = Application.ProductName; string ver = Application.ProductVersion; ver = ver.Replace(".", ""); return(Convert.ToInt32(ver)); }
//===================================================================== /// <summary> /// Constructor /// </summary> public AboutDlg() { InitializeComponent(); Assembly asm = Assembly.GetExecutingAssembly(); var titleAttr = (AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute(asm, typeof(AssemblyTitleAttribute)); var versionAttr = (AssemblyInformationalVersionAttribute)AssemblyInformationalVersionAttribute.GetCustomAttribute( asm, typeof(AssemblyInformationalVersionAttribute)); var descAttr = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute)); // Set the labels this.Title = "About " + titleAttr.Title; tbApplicationName.Text = titleAttr.Title; tbVersion.Text = "Version: " + versionAttr.InformationalVersion; tbDescription.Text = descAttr.Description; }
/// <summary> /// 用于安装的类 /// </summary> public FokiteCoreInstaller() { AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)); AssemblyTitleAttribute title = (AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)); AssemblyProductAttribute displayname = (AssemblyProductAttribute)AssemblyProductAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)); using (processInstaller = new ServiceProcessInstaller()) { serviceInstaller = new ServiceInstaller(); processInstaller.Account = ServiceAccount.LocalSystem; serviceInstaller.StartType = ServiceStartMode.Automatic; serviceInstaller.ServiceName = title.Title; serviceInstaller.DisplayName = displayname.Product; serviceInstaller.Description = description.Description; Installers.Add(serviceInstaller); Installers.Add(processInstaller); } }
/// <summary> /// Load the controls on the forms with data /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void AboutDlg_Load(object sender, System.EventArgs e) { // Get assembly information not available from the application object Assembly asm = Assembly.GetExecutingAssembly(); AssemblyDescriptionAttribute aDescr = (AssemblyDescriptionAttribute) AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute)); AssemblyCopyrightAttribute aCopyright = (AssemblyCopyrightAttribute) AssemblyCopyrightAttribute.GetCustomAttribute(asm, typeof(AssemblyCopyrightAttribute)); // Set the labels this.Text = "About " + Application.ProductName; lblName.Text = Application.ProductName; lblVersion.Text = "Version: " + Application.ProductVersion; lblDescription.Text = aDescr.Description; lblCopyright.Text = aCopyright.Copyright; lnkHelp.Text = Settings.Default.AuthorEMailAddress; lnkEWoodruffUrl.Text = Settings.Default.EWoodruffURL; lnkProjectUrl.Text = Settings.Default.ProjectURL; // Display components used by this assembly sorted by name AssemblyName[] anComponents = asm.GetReferencedAssemblies(); foreach (AssemblyName an in anComponents) { ListViewItem lvi = lvComponents.Items.Add(an.Name); lvi.SubItems.Add(an.Version.ToString()); } lvComponents.Sorting = SortOrder.Ascending; lvComponents.Sort(); // Set the e-mail and URL links lnkHelp.Links[0].LinkData = "mailto:" + lnkHelp.Text + "?Subject=" + Application.ProductName; lnkEWoodruffUrl.Links[0].LinkData = lnkEWoodruffUrl.Text; lnkProjectUrl.Links[0].LinkData = lnkProjectUrl.Text; }
private void LoadAssemblies(string asmName) { asm = Assembly.LoadFrom(asmName); AssemblyDescriptionAttribute atrDescr = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute)); string hash = atrDescr.Description; AssemblyTitleAttribute atrName = (AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute(asm, typeof(AssemblyTitleAttribute)); string name = atrName.Title; HashTable hashTable = new HashTable(); if (hashTable.Check(name, hash)) { assemblies.Add(asm); Type type = typeof(object); IDeserializator des = new Deserializatores.CarDeserealizator(); ISerializer ser = new StandartSerializer(); foreach (Type t in asm.GetTypes()) { if (t.IsClass && typeof(ITransport).IsAssignableFrom(t)) { type = t; } if (t.IsClass && typeof(IDeserializator).IsAssignableFrom(t)) { des = (IDeserializator)Activator.CreateInstance(t); } if (t.IsClass && typeof(ISerializer).IsAssignableFrom(t)) { ser = (ISerializer)Activator.CreateInstance(t); } } objectDeserializer.AddDeserializator(type, des); objectDeserializer.AddSerializator(type, ser); } else { MessageBox.Show("Wrong sign of plugin!"); } }
internal void EmitHeader() { LogMessage(LogLevel.Info, "".PadRight(120, '─'), new object[] { }); //! Type of attribute that is desired Type type = typeof(AssemblyDescriptionAttribute); Assembly asm = Assembly.GetExecutingAssembly(); //! Is there an attribute of this type already defined? if (AssemblyDescriptionAttribute.IsDefined(asm, type)) { //! if there is, get attribute of desired type AssemblyDescriptionAttribute ada = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(asm, type); LogMessage(LogLevel.Info, ada.Description, new object[] { }); } FileVersionInfo vi = FileVersionInfo.GetVersionInfo(asm.Location); LogMessage(LogLevel.Info, "{0} v{1}", new object[] { vi.ProductName.ToString(), vi.FileVersion.ToString() }); LogMessage(LogLevel.Info, vi.LegalCopyright, new object[] { }); LogMessage(LogLevel.Info, "".PadRight(120, '─'), new object[] { }); }
/// <summary> /// Initializes a new instance of the <see cref="AboutDialog"/> class. /// </summary> /// <param name="parentForm">The parent form.</param> public AboutDialog(Form parentForm) { this.InitializeComponent(); // Setup form information Assembly assembly = this.GetType().Assembly; AssemblyCopyrightAttribute copyrightAttribute = (AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute(assembly, typeof(AssemblyCopyrightAttribute)); this.CopyrightLabel.Text = copyrightAttribute.Copyright; AssemblyDescriptionAttribute descriptionAttribute = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)); this.DescriptionLabel.Text = descriptionAttribute.Description; AssemblyProductAttribute productAttribute = (AssemblyProductAttribute)AssemblyProductAttribute.GetCustomAttribute(assembly, typeof(AssemblyProductAttribute)); this.NameLabel.Text = productAttribute.Product; AssemblyFileVersionAttribute fileVersionAttribute = (AssemblyFileVersionAttribute)AssemblyTitleAttribute.GetCustomAttribute(assembly, typeof(AssemblyFileVersionAttribute)); this.VersionLabel.Text = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", fileVersionAttribute.Version, assembly.GetName().Version); this.Text = string.Format(CultureInfo.InvariantCulture, "About {0}", productAttribute.Product); if (parentForm == null) { return; } this.Icon = parentForm.Icon; this.picIcon.Image = parentForm.Icon.ToBitmap(); }
public MemcachedServiceInstaller() { _logger = LogManager.GetLogger(this.GetType().Name); ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller(); ServiceInstaller serviceInstaller = new ServiceInstaller(); serviceProcessInstaller.Account = ServiceAccount.LocalSystem; serviceProcessInstaller.Username = null; serviceProcessInstaller.Password = null; #region /* Si le service est installé dans /Program Files/, vérifie que le déploiement s'est effectué dans le bon dossier sur plateforme 64 bits. * On ne peut se baser sur le contexte courant car l'installation du service peut être initiée par une application 32 bits. * */ if (Is64BitOperatingSystem) { PortableExecutableKinds peKind; ImageFileMachine imgMachine; MemcachedService._applicationAssembly.ManifestModule.GetPEKind(out peKind, out imgMachine); var x86Pf = GetProgramFilesX86Path(); // .NET >= 4.0 : utiliser Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) var nativePf = Environment.GetEnvironmentVariable("ProgramFiles"); // on ne peut se baser sur Environment.SpecialFolder.ProgramFiles en mode WOW64. if (MemcachedService._applicationPath.StartsWith(nativePf, StringComparison.OrdinalIgnoreCase)) { // Vérification appliquée uniquement si installation dans "Program Files" ou "Program Files (x86)". if (peKind == PortableExecutableKinds.Required32Bit) { // Valide l'installation dans pfx86 if (!MemcachedService._applicationPath.StartsWith(x86Pf, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException(string.Format("Dossier d'installation du service erroné: {0}.\r\nVeuillez placer l'application dans le dossier {1} (plateforme ciblée: 32 bits).", MemcachedService._applicationPath, x86Pf)); } } else { // Valide l'installation dans pf if (MemcachedService._applicationPath.StartsWith(x86Pf, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException(string.Format("Dossier d'installation du service erroné: {0}.\r\nVeuillez placer l'application dans le dossier {1} (plateforme 64 bits).", MemcachedService._applicationPath, nativePf)); } } } } #endregion // memcached 64 bits uniquement: limite donc ce process à une plateforme 64 bits: if (IntPtr.Size != 8) { throw new InvalidOperationException("Ce service doit être installé sur une plateforme 64 bits."); } serviceInstaller.DisplayName = string.Format("MemcachedService64 ({0})", Path.GetFileName(MemcachedService._applicationPath)); // permet d'identifier les éventuelles différentes instances de ce service en fonction du nom du dossier content cet assemblage... serviceInstaller.StartType = ServiceStartMode.Automatic; //.NET >= 4.0: serviceInstaller.DelayedAutoStart = true; try { serviceInstaller.Description = ((AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute))).Description; } catch { } serviceInstaller.ServiceName = MemcachedService._serviceName; this.Installers.Add(serviceProcessInstaller); this.Installers.Add(serviceInstaller); }
public static string GetDescription() { //Type of attribute that is desired Type type = typeof(AssemblyDescriptionAttribute); //Is there an attribute of this type already defined? if (AssemblyDescriptionAttribute.IsDefined(Assembly.GetExecutingAssembly(), type)) { //if there is, get attribute of desired type AssemblyDescriptionAttribute assemblyDescriptionAttribute = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), type); return(assemblyDescriptionAttribute.Description); } return(null); }