In C# one can use System.Version.Assembly to get the version of a running app. However this doesn't appear to exist in Silverlight for Windows Phone. Is there an alternative?
+3
A:
You can use the GetExecutingAssembly method and the AssemblyName class to find this information.
var nameHelper = new AssemblyName(Assembly.GetExecutingAssembly().FullName);
var version = nameHelper.Version;
var full = nameHelper.FullName;
var name = nameHelper.Name;
Walt Ritscher
2010-09-30 21:19:09
This doesn't work on Windows Phone because none of these properties are exposed.
henry
2010-10-13 19:23:35
I'm not sure what phone you have, but this code works on the Windows Phone 7.
Walt Ritscher
2010-10-26 14:37:05
+1
A:
On Phone 7 there is no clean way to get the version. The best thing to do is parse the Full Name (which is the only exposed property) for the version string:
String appVersion = System.Reflection.Assembly.GetExecutingAssembly().FullName.Split('=')[1].Split(',')[0];
henry
2010-10-13 19:24:08