我想从我的C#类库中的WinForm项目中获取AssemblyCompany属性.在WinForms中,我可以使用以下方式获取此信息:
Application.CompanyName;
Run Code Online (Sandbox Code Playgroud)
但是,我似乎找不到使用类库获取相同信息的方法.你能提供的任何帮助都会很棒!
Rex*_*x M 28
要获取当前代码(类库代码)实际所在的程序集,并读取其公司属性:
Assembly currentAssem = typeof(CurrentClass).Assembly;
object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
if(attribs.Length > 0)
{
string company = ((AssemblyCompanyAttribute)attribs[0]).Company
}
Run Code Online (Sandbox Code Playgroud)
您可以使用FileVersionInfo类来获取更多CompanyName.
Dim info = FileVersionInfo.GetVersionInfo(GetType(AboutPage).Assembly.Location)
Dim companyName = info.CompanyName
Dim copyright = info.LegalCopyright
Dim fileVersion = info.FileVersion
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7335 次 |
最近记录: |