Assembly: version

R

Russ Green

I'm trying to retrieve the version attribute of the current assembly in
Console and Service applications. I've tried the following method but it
doesn't work for me. Any ideas:

' Return the assembly's Version attribute value.
Public Function GetAssemblyVersion() As String
Dim m_MyAssembly As [Assembly] = [Assembly].GetExecutingAssembly

If m_MyAssembly.IsDefined(GetType(AssemblyVersionAttribute), True) Then
Dim attr As Attribute = _
Attribute.GetCustomAttribute(m_MyAssembly,
GetType(AssemblyVersionAttribute))
Dim version_attr As AssemblyVersionAttribute = DirectCast(attr,
AssemblyVersionAttribute)
Return version_attr.Version.ToString
Else
Return ""
End If
End Function


TIA

Russ
 
B

Ben Eaton

Try this:

Dim objAssembly As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly
Dim objVersion As Version = objAssembly.GetName.Version

System.Diagnostics.Debug.WriteLine(objVersion.ToString)

hth

~Ben
 

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

Top