This is a quick and easy way I found to print the current version number as outlined in your AssemblyInfo.cs file for printing in an ASP.NET MVC view:
[sourcecode language='html']
<%= typeof(MyController).Assembly.GetName().Version.ToString() %>
Replacing MyController of course with your appropriate MVC controller name. This technique may not just apply to ASP.NET MVC, I suppose if you fed the typeof() statement a class name to your main executing class even in a Web App or Windows App this would work.
Don't do the mistake I did and reference typeof(MyController).GetType().Assembly... as this will return 'mscorlib'
Post a Comment