By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Assembly: version

P: n/a
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(AssemblyVersionAttr ibute), 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
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try this:

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

System.Diagnostics.Debug.WriteLine(objVersion.ToSt ring)

hth

~Ben

"Russ Green" <ma*****@SPAM-russgreen.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
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(AssemblyVersionAttr ibute), 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

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.