我希望得到我的C#类图书馆内从一个WinForm项目AssemblyCompany属性。在的WinForms,我可以用得到这样的信息:
I would like to get the AssemblyCompany attribute from a WinForm project inside of my C# class library. In WinForms, I can get to this information by using:
Application.CompanyName;
不过,我似乎无法找到一种方式来获得,在使用类库,同样的信息。任何帮助,您可以提供将是伟大的!
However, I can't seem to find a way to get at that same information using a class library. Any help you could provide would be great!
要获得当前您的code(类库code)实际所在的组装,并读取其公司属性:
To get the assembly in which your current code (the class library code) actually resides, and read its company attribute:
Assembly currentAssem = typeof(CurrentClass).Assembly;
object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
if(attribs.Length > 0)
{
string company = ((AssemblyCompanyAttribute)attribs[0]).Company
}