How to properly get a Windows Phone app's assembly version

I've been seeing code floating around that suggests that in order for you to get an assembly's version number in Windows Phone SDK 7.0/7.1 you have to call Assembly.ToString() or Assembly.FullName and then parse the output. Please don't do that. There is a better, more stable, and more supported way to get the information you seek:

new System.Reflection.AssemblyName(System.Reflection.Assembly.GetExecutingAssembly().FullName)

That will give you an AssemblyName object, which has not only the version number, but other information about your assembly as well.

 
comments powered by Disqus