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?
You can use FileVersionInfo like this:
var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
var companyName = versionInfo.CompanyName;
George Duckett
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
}
Similar for the copyright. (Use the AssemblyCopyrightAttribute
).
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;
}
来源:https://stackoverflow.com/questions/19384193/get-company-name-and-copyright-information-of-assembly