Skip to content

June 20, 2010

1

Get Application GUID at Runtime

The following “snippit” (a bit long, but meh) will retrieve your application’s GUID (which can normally be found in the AssemblyInfo file). Great for referencing your application in the event that the name might change or any other time you need to uniquely identify it.

Dim guid As String = New Guid(CType(Me.GetType.Assembly._
GetCustomAttributes(GetType(Runtime.InteropServices. _
GuidAttribute),False)(0), Runtime.InteropServices. _
GuidAttribute).Value).ToString
Read more from .NET, Development
1 Comment Post a comment
  1. Nando
    Jan 26 2013

    I think this might work better in most cases:

    Public myguid As String = New Guid(CType(My.Application.GetType.Assembly.GetCustomAttributes(GetType(Runtime.InteropServices. _
    GuidAttribute), False)(0), Runtime.InteropServices.GuidAttribute).Value).ToString

Share your thoughts, post a comment.

(required)
(required)

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments