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;
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
.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With