HomeWindowsRetreive the version number from Assembly in Windows Phone 7

Retreive the version number from Assembly in Windows Phone 7

Have you tried retreiving the version number from the current Assembly  in Windows Phone 7?. You might get the Assembly version in .NET something like this

Version assemblyVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

From the above assembly snippet , we get the Major , Minor , Build and Revision from the assemblyVersion .

But when you try the same code snippet in Windows Phone 7 , you might get an exception .

Here’s another alternative way to retreive the version number from the current Assembly in Windows Phone 7.

var CurrentAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName;
string VersionNumber = "Version=  " + CurrentAssembly.Split('=')[1].Split(',')[0];

This should display the version number . Note that i have used the Coding4fun AboutPromt Control as shown in the screenshot below to display the version number from Assembly in Windows Phone 7.

    3 Comments

  1. George Birbilis
    November 25, 2011
    Reply

    The AboutPrompt control shown above is totally non-Metro style. The name/value pairs should be in separate lines

  2. George Birbilis
    November 26, 2011
    Reply

    you should write:

    var CurrentAssembly = System.Reflection.Assembly.GetExecutingAssembly().FullName;

    since readers might not know where to find Assembly class (you have it in the 1st one with full name, but since you say that one is wrong readers may get confused and think [like I did at 1st] they can’t use System.Reflection APIs in WP7 at all)

  3. November 26, 2011
    Reply

    Thanks George for the feedback … i have modified it …

Leave a Reply

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...