Note: This article relates to VS2003. I have not tried this in VS2005 yet.
I came across a little funny behavior today in my application. I use the CommonAppDataPath to access persisted data files. As such, a change in version number is a bit sticky as the version number is included in the CommonAppDataPath. So for instance I have the following path where my data is stored:
C:\Documents and Settings\Chaz\Local Settings\Application Data\CompanyName\ProgramName\1.0.2006.0102\Data
The entry in the AssemblyInfo file is;
<Assembly: AssemblyVersion("1.0.2006.0102")>
For my own reasons I want to keep the version number static until I make a change in my object model that breaks compatibility with my serialized files. However, I also want to be able to definitively identify what build my users are working with and I don't want to trust file sizes, dates etc.
So I thought I would add the AssemblyInformationalVersion to my AssemblyInfo file. Then I could just display that in my “About“ box.
The entry in the AssemblyInfo file is;
<Assembly: AssemblyInformationalVersion("7.0.0")>
As I tried to test these changes I found a problem. The real problem is a misinterpretation of the MSDN documentation:
The first MSDN article I read “Understanding and Using Assemblies and Namespaces in .NET“. It says:
“AssemblyInformationalVersion - Human-readable version; not used by the common language runtime“
The second MSDN article I read “Application.CommonAppDataPath Property“ says:
“ProductVersion first looks to see if the assembly containing the main executable has the AssemblyInformationalVersion attribute on it. If this attribute exists, it is used for both ProductVersion and CommonAppDataPath. If this attribute does not exist, both properties use the version of the executable file instead.”
Okay, I could have misinterpreted the documentation in the first article as it doesn't say other namespaces within the .NET framework do not use the data assigned to the AssemblyInformationalVersion attribute. It says “not used by the common language runtime“.
But the VS2003 MSDN documentation also says;
“The attribute defined by this class attaches additional version information to an assembly for documentation purposes only. This data is never used at runtime.”
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemreflectionassemblyinformationalversionattributeclasstopic.htm
So just be careful when using the AssemblyInformationalVersion attribute when you are also using the CommonAppDataPath.
--chaz