Use AssemblyInfo?
-
Hi, The AssemblyInfo.cs file contains attributes, such as AssemblyVersion, which I want to use programatically, as in an About dialog. I have looked at the AssemblyVersionAttribute class, but I can't find any examples showing how to use it. Any help on this would be greatly appreciated. Thanks, Royce
-
Hi, The AssemblyInfo.cs file contains attributes, such as AssemblyVersion, which I want to use programatically, as in an About dialog. I have looked at the AssemblyVersionAttribute class, but I can't find any examples showing how to use it. Any help on this would be greatly appreciated. Thanks, Royce
-
Hi, The AssemblyInfo.cs file contains attributes, such as AssemblyVersion, which I want to use programatically, as in an About dialog. I have looked at the AssemblyVersionAttribute class, but I can't find any examples showing how to use it. Any help on this would be greatly appreciated. Thanks, Royce
Hi Royce! The AssemblyInfo.cs file contains attributes, such as AssemblyVersion, which I want to use programatically, as in an About dialog. I suggest you should use the classes in the
System.Reflection
namespace rather than the ones fromSystem.Windows.Forms
because retrieving metadata from assemblies is exactly what the reflection classes were made for.Version MyVersion = Assembly.GetExecutingAssembly().GetName().Version;
MessageBox.Show(MyVersion.ToString());Best regards Dennis
-
Hi, The AssemblyInfo.cs file contains attributes, such as AssemblyVersion, which I want to use programatically, as in an About dialog. I have looked at the AssemblyVersionAttribute class, but I can't find any examples showing how to use it. Any help on this would be greatly appreciated. Thanks, Royce
More generically (i.e. if you plan to use custom attributes or there is a possibility that you will be inspecting third party assemblies that may do so), you could do something like this:
object[] attribs = Assembly.GetExecutingAssembly().GetCustomAttributes(true);
That will return all of the custom attributes applied to the executing assembly either directly or through inheritance.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’