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!
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 }
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With