Is it possible to retrieve this value at runtime?
I'd like to keep the value in one place, and retrieve it whenever my application needs to output the name of my company.
Is it possible to retrieve this value at runtime?
I'd like to keep the value in one place, and retrieve it whenever my application needs to output the name of my company.
This should do it:
using System.Reflection;
string company = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(
Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute), false))
.Company;
If you really want to keep the value in one place and you have multiple assemblies in your solution, you could either:
GetEntryAssembly
instead of GetExecutingAssembly
and set the company attribute only on your entry assembly, or better:UPDATE
Improved the code by suggestion of @hmemcpy so it doesn't need [0]
anymore. Thanks!