esarjeant esarjeant - 1 year ago 99
C# Question

Method for Application Version on a Console Utility App

What is the best method for displaying major/minor versions in a C# console application?

The System.Windows.Forms namespace includes a ProductVersion class that can be used to display the name/version information set via the Visual Studio project properties (Assembly Information). As such, here is my current mechanism:

Console.WriteLine("{0} ({1})", System.Windows.Forms.Application.ProductName, System.Windows.Forms.Application.ProductVersion);

Why is this part of Forms? Is this appropriate for a Console application?

Answer Source

Also, you can still use the class, you just have to reference the containing assembly. It's no biggie.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download