Anders G. Nordby

Senior Systems Consultant at CGI

Monthly Archives: January 2013

Displaying Assembly Version Info in EPiServer CMS 6.0 R2

My current customer has asked for a way to know what version we have deployed in the various environments (test, staging, production), and we agreed that displaying the assembly version of our main project DLL is a good way of achieving this. This can also be helpful during testing, as the customer can include the version number in the bug reports. So, how can we accomplish this task?

We’re using MSBuild and Team City in this project, and this blogpost explained how to set the assembly version number of the DLL: Simple MSBuild Configuration: Updating Assemblies With A Version Number

Then I created a simple plugin:

<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="MakingWavesVersionInfo.aspx.cs" Inherits="MyProject.Plugins.MakingWavesVersionInfo" Title="Making Waves Version Info Plugin" %>
<%@ Import Namespace="EPiServer" %>
<%@ Import Namespace="EPiServer.Shell" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head id="Head1" runat="server">
    <title>Making Waves Version Info</title>

    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/App_Themes/Default/styles/system.css") %>">
    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/App_Themes/Default/styles/ToolButton.css") %>">
    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/styles/multipageproperty.css") %>">
    <link rel="stylesheet" type="text/css" href="<%= Paths.ToShellResource("ClientResources/Shell.css")  %>"/>
    <link rel="stylesheet" type="text/css" href="<%= Paths.ToShellResource("ClientResources/ShellCoreLightTheme.css")  %>"/>
    <link rel="stylesheet" type="text/css" href="<%= UriSupport.ResolveUrlFromUIBySettings("ClientResources/Epi/Base/CMS.css")  %>"/>
    <form id="form1" runat="server">
        <div class="epi-contentContainer epi-padding">
            <div class="epi-contentArea">
                <h1>Making Waves Version Info</h1>
                <p>MyProject.dll: <%= GetAssemblyVersion("MyProject")%></p>
                <p>ThirdParty.dll: <%= GetAssemblyVersion("ThirdParty")%></p>

Notice how it’s easy to list of the various DLLs for which the customer wants to see the version number.

using System;
using System.Reflection;
using System.Threading;
using EPiServer;
using EPiServer.PlugIn;
using System.Linq;

namespace MyProject.Plugins
    [GuiPlugIn(DisplayName = "Making Waves Version Info", Description = "Making Waves Version Info", Area = PlugInArea.ActionWindow, Url = "~/Plugins/MakingWavesVersionInfo.aspx")]
    public partial class MakingWavesVersionInfo : SimplePage
        private readonly Assembly[] _myAssemblies = Thread.GetDomain().GetAssemblies();

        protected override void OnInit(EventArgs e)

            // Making sure only editors can reach this plugin
            if (!EPiServer.Security.PrincipalInfo.HasEditAccess)

        protected void Page_Load(object sender, EventArgs e)


        protected string GetAssemblyVersion(string assemblyName)

            var myAssembly =
                _myAssemblies.FirstOrDefault(assembly => string.CompareOrdinal(assembly.GetName().Name, assemblyName) == 0);

            return myAssembly != null
                       ? myAssembly.GetName().Version.ToString()
                       : "Could not get assembly version.";

Not a very complicated thing to do, but I think this is a good idea – and I might just continue to do this in future projects as well. I’m sure that easily being able to see what version is deployed can come in very handy.

The result looks like this in the EPiServer edit mode: