Winforms: getting Publish Version number?

Milo Kofax picture Milo Kofax · May 7, 2013 · Viewed 20.3k times · Source

I've got a Winforms app and want to display the version number so that we can know if our update scripts are running correctly. Is there a way to get the Publish Version number (as displayed in the Property Pages of the app, Publish tab)?

When I use Reflection.Assembly.GetExecutingAssembly().GetName().Version etc it seems to use the AssemblyVersion number from AssemblyInfo.vb, which isn't the same.

If I use wildcards in the AssemblyInfo.vb it comes out different numbers again.

Answer

GJKH picture GJKH · May 7, 2013

This should get you the publish version:

ApplicationDeployment.CurrentDeployment.CurrentVersion