从类库检索AssemblyCompanyName [英] Retrieve AssemblyCompanyName from Class Library

查看:139
本文介绍了从类库检索AssemblyCompanyName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望得到我的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
}

这篇关于从类库检索AssemblyCompanyName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆