Winforms:获取发布版本号? [英] Winforms: getting Publish Version number?
问题描述
我有一个 Winforms 应用程序,想显示版本号,以便我们知道我们的更新脚本是否正确运行.有没有办法获取发布版本号(如应用程序的属性页中的发布"选项卡中所示)?
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)?
当我使用 Reflection.Assembly.GetExecutingAssembly().GetName().Version 等时,它似乎使用了 AssemblyInfo.vb 中的 AssemblyVersion 编号,这并不相同.
When I use Reflection.Assembly.GetExecutingAssembly().GetName().Version etc it seems to use the AssemblyVersion number from AssemblyInfo.vb, which isn't the same.
如果我在 AssemblyInfo.vb 中使用通配符,它会再次出现不同的数字.
If I use wildcards in the AssemblyInfo.vb it comes out different numbers again.
推荐答案
这应该会为您提供发布版本:
This should get you the publish version:
ApplicationDeployment.CurrentDeployment.CurrentVersion
这篇关于Winforms:获取发布版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!