.net – Version number in .NET Compact Framework application

compact-frameworknet

I need to display the .NET Compact Framework version number on the screen. I am using .NET CF 2.0 with Windows CE 4.0.

So far, I have been ignoring the version number completely. Do I need to add anything to the assembly? how do I retrieve it programmatically?


Unfortunately this does not apply to Compact Framework. The Application.ProductVersion property doesn't exist in Compact Framework. The latest part of your answer applies though.

One more question:
do these properties (major, minor, build, revision) get incremented automatically or do I set them whenever I want to? The way I see it, the revision should be automatically incremented with each new build.

Best Answer

System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision

Source: http://msdn.microsoft.com/en-us/library/system.version.aspx

(Edit)

Application.ProductVersion Property

Gets the product version associated with this application.

Not Available In Compact Framework But System.Reflection.Assembly.GetExecutingAssembly().GetName().Version Is.

Source: http://msdn.microsoft.com/en-us/library/system.windows.forms.application.productversion.aspx