VB.NET/Visual Studio 2008-如何在运行时访问REVISION号? [英] VB.NET / Visual Studio 2008 - how do i access the REVISION number at run time?
问题描述
我只是想在主表单上打印出修订号,因此用户可以查看他们正在运行的版本(修订).
在VS2008中,它为我自动增加了修订号,但是我不知道如何在运行时访问相同的修订号.
我尝试过...
I''d simply like to print out the revision number on the main form, so the users could have a way of seeing what version (revision) they are running.
It auto-increments the revision number for me in VS2008, but I can''t figure out how to access that same number at runtime.
I''ve tried...
Dim xversion As String
xversion = My.Application.Info.Version.ToString
和
and
xversion = System.Windows.Forms.Application.ProductVersion.ToString
以及我在网上阅读的其他一些示例.似乎很容易抓住.
我还尝试设置 AssemblyInfo.vb 文件代码以读取
and a few other examples I''ve read online. Seems like this would be easy to grab.
I''ve also tried setting the AssemblyInfo.vb file code to read
<assembly: xmlns:assembly="#unknown"></assembly:>
仍然没有运气.
Still no luck. This is on a windows forms application... any advice/reply would be appreciated.
推荐答案
为什么不使用真正的通用方法?
Why not using really universal method?
System.Reflection.Assembly.GetEntryAssembly().GetName().Version
'' or:
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
'' or any other assembly
我们也可以尝试
We can also try
Public Class Class1
Dim currentAppVersion = My.Application.Deployment.CurrentVersion
Dim lastUpdateDate = My.Application.Deployment.TimeOfLastUpdateCheck
End Class
如果部署模型是单击一次",则获取版本.
to retrive the version, if the deployment model is ''Click Once''
My.Application.Info.Version
是类型为<a href="http://msdn.microsoft.com/en-us/library/system.version.aspx">System.Version</a>[<a href="http://msdn.microsoft.com/en-us/library/system.version.aspx" target="_blank" title="New Window">^</a>]
的对象.
您可以从该对象属性(包括修订版)中获取所有版本信息.
TheMy.Application.Info.Version
is an object of type<a href="http://msdn.microsoft.com/en-us/library/system.version.aspx">System.Version</a>[<a href="http://msdn.microsoft.com/en-us/library/system.version.aspx" target="_blank" title="New Window">^</a>]
.
You can get all the version information from that object properties including revision.
这篇关于VB.NET/Visual Studio 2008-如何在运行时访问REVISION号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!