Retrieve AssemblyCompanyName from Class Library
To get the assembly in which your current code (the class library code) actually resides, and read its company attribute:
Assembly currentAssem = typeof(CurrentClass).Assembly;
object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
if(attribs.Length > 0)
{
string company = ((AssemblyCompanyAttribute)attribs[0]).Company
}
The dotnet 5 version:
typeof(CurrentClass).GetCustomAttribute<AssemblyCompanyAttribute>().Company
Assembly assembly = typeof(CurrentClass).GetAssembly();
AssemblyCompanyAttribute companyAttribute = AssemblyCompanyAttribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
if (companyAttribute != null)
{
string companyName = companyAttribute.Company;
// Do something
}
You could use the FileVersionInfo
class to get CompanyName
and much more.
Dim info = FileVersionInfo.GetVersionInfo(GetType(AboutPage).Assembly.Location)
Dim companyName = info.CompanyName
Dim copyright = info.LegalCopyright
Dim fileVersion = info.FileVersion