.NET Framework - Assembly version vs. File version

Asked By Zytan on 28-Apr-07 02:20 PM
In the Assembly Information, you can set the assembly version and the
file version.  What is the difference between the two?  The
documentation is not exactly helpful in this area.

I had the assembly version set to a unique number, and just left the
file version as 0.0.0.0.  My program crashed on another computer, and
the windows error report stated: "AppVer: 0.0.0.0", so I am thinking
maybe the file version is more important (unless this was an older
version of my program that had BOTH assembly and file version set to
0.0.0.0).

When you right-click properties of a file, it shows the File version
at the top, and both assembly and file versions inthe list box at the
bottom, with assembly listed first.

It is totally unclear to me what either is for, which is more
important.  For now, I'll just set them to both be the same.

Zytan




Marc Gravell replied on 28-Apr-07 05:06 PM
Without trying to sound daft, the assembly version controls the
version of the assembly, and the file version controls the version of
the file. If may be useful to keep them in sync, but note that
by .Net, but may be used by OS tools. Changing the assembly version of
a strongly named assembly generally requires you to tell the callers
to forward to the new version (via policy), else recompile.

Right or wrong, I have tweaked my build process to timestamp the build
into the file version, but it leaves the assembly version for manual
planned change. That way I can always track the history of a dll,
without quite as much pain for releasing a hotfix as changing the
assembly version.

Marc
Ignacio Machin \( .NET/ C# MVP \) replied on 28-Apr-07 11:44 PM
Hi Marc,

Would you mind share with us how u did it?


Thanks,
Ignacio
Marc Gravell replied on 29-Apr-07 04:23 PM
Nothing very sophisticated I'm afraid. I considered some funky MSBuild
add-ins, but chickened out. Basically I have a build script (actually
a C# exe) that traverses a source tree looking for things to build
(updating references / dependencies, setting config for the
environment [WCF endpoints, etc], figuring out the build order etc); I
simply added a few lines into that which use a regex to find and
update the necessary attribute in the source code. Similar to the
standard VS auto-versioning, but with an offset that won't run out of
numbers for a few extra decades.

Sorry it wasn't something more exciting ;-p

Marc
Zytan replied on 29-Apr-07 07:42 PM
Ok, so basically the assembly is one whole compilation, and that has a
number.  But, the file version refers to the final .exe made, so it is
also the entire assembly.  I still fail to see the difference.

Maybe someone can explain what the difference between file and
assembly is in terms of a final exe file?

Thanks,
Zytan
Mattias Sjögren replied on 30-Apr-07 04:12 AM
You can create so called multi-module assemblies, where one assembly
spans over more than one executable file. It's not that common, but in
such a scenario you'd have a single assembly version while each
executable could have its own file version.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Zytan replied on 30-Apr-07 08:41 PM
Ok thanks, Mattias

Zytan