Assembly and File Version Information in WinRT

How to get the assembly and file version information in WinRT apps

Short and simple post this time. If you need to get the assembly and file version information in your Windows Store app, here is what you need. Note that the using System.Reflection is important since the GetTypeInfo() method is an extension method in that namespace.

using System;
using System.Reflection;

namespace Example
{
    public class VersionInformation
    {
        public VersionInformation()
        {
            var assembly = this.GetType().GetTypeInfo().Assembly;
            var assemblyVersion = assembly.GetName().Version.ToString();
            var fileVersion = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
            var productVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
            System.Diagnostics.Debug.WriteLine("Assembly Version: " + assemblyVersion);
            System.Diagnostics.Debug.WriteLine("File Version: " + fileVersion);
            System.Diagnostics.Debug.WriteLine("Product Version: " + productVersion);
        }
    }
}

Similar, but slightly different than in other versions of .NET since Assembly.GetExecutingAssembly() and System.Diagnostics.FileVersionInfo are not available. Hope that helps somebody out.

 

@briandunnington


2018.11.27

Deploying Azure Web App Certificates from Key Vault

How to work around an ARM template limitation when using a Key Vault certificate in a Web App

View details »


2018.11.06

Roku Round-up

Quick updates on some Roku libraries that I recently released

View details »


2018.10.09

CORS and exceptions on ASP.NET Core

How to ensure your CORS headers are properly returned with HTTP error responses on ASP.NET Core

View details »


2018.03.25

The many uses of Azure Functions Proxies

Azure Functions Proxies are awesome - here are just a few ways to leverage them

View details »


2018.03.12

Build an Alexa skill using Azure Functions

Although AWS Lambdas are the default, it is dead simple to use Azure Functions for your Alexa skill as well

View details »


More Posts >