tags:

views:

26

answers:

2

On the publish tab of My Project the correct current version is there, 1.1.0.0 and in Programs and Features under Control Panel it shows 1.1.0.0 but when I reference Application.ProductVersion I get 1.0.0.0.

What am I doing wrong or what am I missing here?

Thanks.

+1  A: 

Hi Tom,

Maybe you should try to explicitly put an attribute on your assembly: for example: [assembly: AssemblyVersion("1.1.0.0")]

Regards, Michael.

MichaelMocko
+2  A: 

Hi Tom,

The assemby version (in the application.config file) and the ClickOnce Publish version are 2 seperate numbers.

If you want to get the ClickOnce version at runtime you can use the following code

     If (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) Then
        With System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion
            Me.Text = "V" & .Major & "." & .Minor & "." & .Build
        End With
     End If
DJIDave
You can only reference those properties if you're running the compiled and deployed version of your app? What about in the development environment?
Tom
This is why I do the if to start with. Using this method you can't access the Deployment version in dev because it isn't deployed. In our applications I tend to do an else and put in a place holder for in the dev environment.
DJIDave
So how do you access the same properties but in the development environment?
Tom
I don't know of an easy way to access this in Dev, the ApplicationVersion is stored in the <appname>.application manifest file, so you could always open that and get the version out of there. The other thing to do is query the Assembly using System.AppDomain.CurrentDomain.GetAssemblies() this will list all assemblies so you can iterate through them until you find yours and the version is embedded in the name
DJIDave
Thanks. To be honest this all seems unneccesarily complicated to get something so easily visible. I will deal with it though, thanks again for your help.
Tom