Assembly Versioning

Problem
You want to know how to version your assemblies and any potential pitfalls.

Solution
Edit the AssemblyVersion(“1.0.0.0”) attribute in the AssemblyInfo.cs file, and give the assembly a specific version number. Change the version number when you publish a new version of the assembly.

Comments
Specifying a version number is important because it gives the assembly a strong name. One gotcha: If you use an asterisk in the version number, the version number changes each time you recompile the assembly. As a result, all client assemblies have to be recompiled and the identity of any enclosed types will change. Further, this will lead to problems when deserializing an object that was serialized by a previous version of the same assembly.

Example

// Incorrect. Uses an asterisk.
[assembly: AssemblyVersion("1.0.*")]

// Correct. Remember to change as needed.
[assembly: AssemblyVersion("1.0.0.0")]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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