Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get company name and copyright information of assembly [duplicate]

I am using Assembly.GetEntryAssembly().GetName() to get application/assembly name and its version but I do not see any variable for company name and copyright. How do I get that?

like image 469
Computer User Avatar asked Oct 15 '13 14:10

Computer User


3 Answers

You can use FileVersionInfo like this:

var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);

var companyName = versionInfo.CompanyName;
like image 162
Alessandro D'Andria Avatar answered Nov 09 '22 18:11

Alessandro D'Andria


From this answer for the company name:

Assembly currentAssem = typeof(CurrentClass).Assembly;
object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
if(attribs.Length > 0)
{
    string company = ((AssemblyCompanyAttribute)attribs[0]).Company;
}

Code is similar for the copyright, use AssemblyCopyrightAttribute instead of AssemblyCompanyAttribute.

like image 42
George Duckett Avatar answered Nov 09 '22 18:11

George Duckett


Those are attributes that you have to enumerate on the Assembly object using reflection.

var attributes = Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);

var attribute = null;
if (attributes.Length > 0)
{
    attribute = attributes[0] as AssemblyCompanyAttribute;
}
like image 5
Mike Dinescu Avatar answered Nov 09 '22 16:11

Mike Dinescu