Sometimes you need to know which version of an assembly was loaded by your .NET application. The following code snippet makes it easy:

using System.Reflection;
using System.Windows.Forms;

static public void ShowAssemblyVersion( Type type )
{
Assembly asm = Assembly.GetAssembly( type );
if (asm != null)
{
AssemblyName asmName = asm.GetName();
string text = String.Format(
“Assembly Name={0} Version={1}”,
asmName.Name, asmName.Version );
MessageBox.Show( text );
}
}

Then to display the assembly version, simply call the ShowAssemblyVersion method defined above, passing any type that’s defined in the assembly. For example, if the class “MyType” is defined in your assembly:

ShowAssemblyVersion( typeof( MyType ) );