[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:
[C#]
[assembly: AssemblyFileVersion("1.0.0")]
[VB]
<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.
This appears to override the System namespace in VB. Does this work in C#?
LikeLike
Doing this as a separate dll eliminates the errors, but also does not apply the FileVersion information.
LikeLike