Get company name and copyright information of assembly [duplicate]

会有一股神秘感。 提交于 2019-12-03 09:31:12

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!