Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve AssemblyCompanyName from Class Library

Tags:

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!

like image 222
Blake Blackwell Avatar asked Oct 26 '09 19:10

Blake Blackwell


2 Answers

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 } 
like image 187
Rex M Avatar answered Nov 07 '22 07:11

Rex M


You could use the FileVersionInfo class to get CompanyName and much more.

Dim info = FileVersionInfo.GetVersionInfo(GetType(AboutPage).Assembly.Location) Dim companyName = info.CompanyName Dim copyright = info.LegalCopyright Dim fileVersion = info.FileVersion 
like image 21
Mike Schall Avatar answered Nov 07 '22 08:11

Mike Schall