HOWTO: Add the Win32 file version to your .NET Compact Framework assemblies

[NOTE: This is an old post from November 15, 2004 by Neil Cowburn that is hit fairly frequently and that I’ve recovered using the Wayback Machine]

Currently, this is only one supported method of setting the Win32 file version of your .NET Compact Framework assemblies. This is by command-line compiling your project using the “/win32res” switch with csc.exe and a Win32 resource file. This is definitely not an optimal solution if you are not familiar with command-line compiling .NET CF apps.

In the .NET Framework, those lucky developers are able to set the Win32 file version using a special attribute in the AssemblyInfo file. However this attribute, System.Reflection.AssemblyFileVersionAttribute, is missing from the .NET Compact Framework. How can we fix this so that we can easily set the Win32 file version? Easy! Add the following code to your project:

using System;
namespace System.Reflection
    [AttributeUsage(AttributeTargets.Assembly, AllowMultiple=false)]
    public class AssemblyFileVersionAttribute : Attribute
        private string version;
        public string Version
            get { return version; }
        public AssemblyFileVersionAttribute(string version)
            if(version == null)
                throw new ArgumentNullException("version");
            this.version = version;

And then, in your AssemblyInfo file, add the following attribute:


[assembly: AssemblyFileVersion("1.0.0")]



<Assembly: AssemblyFileVersion("1.0.0")>


Compile your project and then check out its property page using Windows Explorer. You should see that the File Version information has been successfully added to your assembly.

2 thoughts on “HOWTO: Add the Win32 file version to your .NET Compact Framework assemblies”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s