Click here to Skip to main content
Licence GPL3
First Posted 22 Oct 2007
Views 8,204
Downloads 21
Bookmarked 12 times

Down and dirty class to retreive assembly data

By | 22 Oct 2007 | Article
Inheritable class for retreving assembly data using VB.NET and .NET Framework 2.0.

Introduction

This is just a simple class to retrieve assembly data from the current application using VB.NET. It will return each of the assembly variables as a string.

Background

It seems that most of the code snippets I could find elsewhere just simply did not work or had lots of complicated forms that I did not need. This one you can just import and it is done.

Using the code

Copy and compile and that's about it, or just download my example and reference the DLL.

Imports SYR = System.Reflection 
Public Class GetAssembly

Private assembType As System.Reflection.Assembly
Public Sub New()
    assembType = System.Reflection.Assembly.GetExecutingAssembly
End Sub

Public ReadOnly Property TName() As String
    Get
    Return assembType.GetName.ToString()
    End Get
End Property

Public ReadOnly Property TFullName() As String
    Get
    Return assembType.GetName.FullName.ToString()
    End Get
End Property

Public ReadOnly Property CodeBase() As String
    Get
    Return assembType.CodeBase.ToString()
    End Get
End Property

Public ReadOnly Property Copyright() As String
    Get
    Dim attype As Type = GetType(SYR.AssemblyCopyrightAttribute) 
    Dim atr() As Object = assembType.GetCustomAttributes(attype, False) 
    Dim ct As SYR.AssemblyCopyrightAttribute = _
              CType(atr(0), SYR.AssemblyCopyrightAttribute) 
    Return ct.Copyright    
    End Get
End Property

Public ReadOnly Property Company() As String
    Get
    Dim attype As Type = GetType(SYR.AssemblyCompanyAttribute) 
    Dim atr() As Object = assembType.GetCustomAttributes(attype, False) 
    Dim ct As SYR.AssemblyCompanyAttribute = CType(atr(0), SYR.AssemblyCompanyAttribute) 
    Return ct.Company    
    End Get
End Property

Public ReadOnly Property Description() As String
    Get
    Dim attype As Type = GetType(SYR.AssemblyDescriptionAttribute) 
    Dim atr() As Object = assembType.GetCustomAttributes(attype, False) 
    Dim da As SYR.AssemblyDescriptionAttribute = _
              CType(atr(0), SYR.AssemblyDescriptionAttribute) 
    Return da.Description    
    End Get
End Property

Public ReadOnly Property Product() As String
    Get
    Dim attype As Type = GetType(SYR.AssemblyProductAttribute)
    Dim atr() As Object = assembType.GetCustomAttributes(attype, False) 
    Dim pt As SYR.AssemblyProductAttribute = _
              CType(atr(0), SYR.AssemblyProductAttribute) 
    Return pt.Product
    End Get
End Property

Public ReadOnly Property Title() As String
    Get
    Dim attype As Type = GetType(SYR.AssemblyTitleAttribute) 
    Dim atr() As Object = assembType.GetCustomAttributes(attype, False)
    Dim ta As SYR.AssemblyTitleAttribute = CType(atr(0), SYR.AssemblyTitleAttribute) 
    Return ta.Title    
    End Get
End Property

Public ReadOnly Property Version() As String
    Get
    Return assembType.GetName.Version.ToString()
    End Get
End Property

End Class

History

  • Version 1.0: No changes yet.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

Prefict

Software Developer (Senior)
MMK Technologies
United States United States

Member

I have been developing applications since 1989. My current project is SpiderLoop an ASP.NET SEO control panel. If you build asp.net applications for clients you should really check it out.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMake the properites/methods static PinmemberMike Mestemaker10:22 22 Oct '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 22 Oct 2007
Article Copyright 2007 by Prefict
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid