tags:

views:

34

answers:

1

In WinForms, I'd use Application.ProductVersion.

I've tried using System.Reflection.Assembly in various ways but can never get the version of just the MVC project.

+3  A: 

Provided this code is explicitly in the MVC project (rather than in a helper assembly), you should be able to use System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(3), which returns the major, minor, and revision numbers. Otherwise you might want to use something like typeof(HomeController).Assembly.GetName().Version.ToString(3).

Agent_9191
`GetExecutingAssembly().GetName()` returns `App_Web_ykccwaz0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null`
mattdwen
Guessing you're running it through the ASP.NET compiler, but the version of the assembly should remain the same. Your AssemblyInfo has a valid version number set for the assembly, right?
Agent_9191
If I check the properties of the MVC project .dll in the /bin directory, it shows the correct assembly version.
mattdwen
I've used `typeof(HomeController).Assembly.GetName().Version.ToString(3)` and it works
mattdwen