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?
问问题
40779 次
3 回答
67
您可以像这样使用FileVersionInfo:
var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
var companyName = versionInfo.CompanyName;
于 2013-10-15T14:53:51.520 回答
14
从公司名称的这个答案中:
Assembly currentAssem = typeof(CurrentClass).Assembly;
object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
if(attribs.Length > 0)
{
string company = ((AssemblyCompanyAttribute)attribs[0]).Company
}
版权类似。(使用AssemblyCopyrightAttribute
)。
于 2013-10-15T14:50:02.400 回答
4
这些是您必须使用反射在 Assembly 对象上枚举的属性。
var attributes = Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
var attribute = null;
if (attributes.Length > 0)
{
attribute = attributes[0] as AssemblyCompanyAttribute;
}
于 2013-10-15T14:49:53.633 回答