从类库中检索AssemblyCompanyName

我想从我的C#类库中的WinForm项目中获取AssemblyCompany属性。 在WinForms中,我可以通过以下方式获取此信息:

Application.CompanyName; 

但是,我似乎找不到使用类库获取相同信息的方法。 你能提供的任何帮助都会很棒!

要获取当前代码(类库代码)实际驻留的程序集,并读取其company属性:

 Assembly currentAssem = typeof(CurrentClass).Assembly; object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true); if(attribs.Length > 0) { string company = ((AssemblyCompanyAttribute)attribs[0]).Company } 
  Assembly assembly = typeof(CurrentClass).GetAssembly(); AssemblyCompanyAttribute companyAttribute = AssemblyCompanyAttribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute; if (companyAttribute != null) { string companyName = companyAttribute.Company; // Do something } 

您可以使用FileVersionInfo类来获取更多CompanyName。

  Dim info = FileVersionInfo.GetVersionInfo(GetType(AboutPage).Assembly.Location) Dim companyName = info.CompanyName Dim copyright = info.LegalCopyright Dim fileVersion = info.FileVersion