开发者

Application.ProductVersion always returns 1.0.0.0

On the publish tab of My Project the correct current version is there, 1.1.0.0 and in Programs and Features un开发者_如何学编程der 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.


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

Edit: For the full, four-segment revision number you'll need:

Me.Text = "V" & .Major & "." & .Minor & "." & .Build & "." & .Revision 


With System.Reflection you can use:

Dim versionNumber As Version

versionNumber = Assembly.GetExecutingAssembly().GetName().Version

and then call .ToString() on that if needed...

and yet another method is to call

System.Windows.Forms.Application.ProductVersion

(for Full Disclosure I found this on MSDN Forums)


I know this is old, but in Visual Studio Express 2013, I ran across the same issue. I wanted to use variable ProductVersion like so:

msgbox (Application.ProductVersion)

but it always returned 1.0.0.0 no matter what I put in the settings for Publish. I found instead I had to put it in Application > Assembly > File Version (I updated both Assembly version and File Version, but it's the File Version that counts).

Application.ProductVersion always returns 1.0.0.0

You get to this using Project > Properties:

Application.ProductVersion always returns 1.0.0.0

Now, I only wanted the major and minor numbers (to concatenate to the form title) so I used this:

MsgBox(Application.ProductVersion.Substring(0, 3))

Hope this helps others. It was a lot of digging!


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

Regards, Michael.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜