Get ProductVersion in Module

  • Thread starter Thread starter Matthew
  • Start date Start date
M

Matthew

Is there an easy way to get the ProductVersion in a Module?

Matthew
 
Matthew,
If the Module in a Windows Application, I normally use
Application.ProductVersion to get the application's product version, then
use the following code to get the product version of specific assemblies:

Private Function GetProductVersion(ByVal [assembly] As
System.Reflection.Assembly) As String
Dim attributes() As Object
attributes =
[assembly].GetCustomAttributes(GetType(System.Reflection.AssemblyInformationalVersionAttribute),
False)
If attributes.Length > 0 Then
Dim assemblyProductVersion As
System.Reflection.AssemblyInformationalVersionAttribute =
DirectCast(attributes(0),
System.Reflection.AssemblyInformationalVersionAttribute)
Return assemblyProductVersion.InformationalVersion
Else
Return String.Empty
End If
End Function



I normally use AssemblyInformationalVersionAttribute to set the Product
Version, then update it manually when I am ready to do a new build.

' somewhere in the AssemblyInfo.vb file:
<Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyInformationalVersion("1.0.0")> ' Product Version

Hope this helps
Jay
 
If the Module in a Windows Application, I normally use
Application.ProductVersion to get the application's product version...

Perfect!
Thank you.

Matthew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top