dauger

Here's an easy one:

What's a good way to get a hold of a console application's version while it is running I'd like to output this information when the program executes.




Re: Visual C# General Displaying Console Application Version Number

OmegaMan

This is done using reflection into the current assembly. Note it prints out the .net version as well.

Code Snippet

using System.Reflection;

...


Assembly execAssembly = Assembly.GetCallingAssembly();

AssemblyName name = execAssembly.GetName();

Console.WriteLine(string.Format("{0}{1} {2:0}.{3:0} for .Net ({4}){0}",
Environment.NewLine,
name.Name,
name.Version.Major.ToString(),
name.Version.Minor.ToString(),
execAssembly.ImageRuntimeVersion
));







Re: Visual C# General Displaying Console Application Version Number

dauger

Just what the doctor ordered. Thanks!