Main Site Documentation

Retrieving AssemblyInfo Attributes at Runtime?


#1

I’ve been trying to retrieve some of the AssemblyInfo.cs attributes at runtime, but can’t seem to figure it out. The .net MF doesn’t work with any of the examples I’ve found online related to C#. Does anyone have an example of retrieving the attributes, such as AssemblyDescription? Thanks.


#2

I think that information is stipped off by the compiler since reading class attibutes is not supported (it would be useful though to have this option). Some values can be accessed at runtime via properties:


            var assembly = Assembly.GetExecutingAssembly().GetName();
            Debug.Print(assembly.Name + " " + assembly.Version);


#3

Thanks for the reply. I saw that name, full name, and version were available from the executing assembly. Unfortunately, the assembly name isn’t necessarily a nice product name you would want to display to users. I did notice that the compiled executable does contain the attributes, which you can see by looking at the properties of the compiled executable itself. So, I’m not sure why the assembly attributes aren’t available. I guess I’ll just make some resource strings and update them and the assembly attributes whenever I change versions, etc. That seems like some uncecessary steps, especially, since the attributes are there.