.NET Assembly Info

Fateseer
06-29-2004, 02:25 PM
Hello!

I'm a long time reader, but this is the first time I've posted (usually find the answers I was looking for without posting).

I'm still attempting to convert from VB6 to VB.NET so forgive me if my terminology slips from time to time. :D

So...I'm building an app and attempting to put in a splash screen that will read the information I put in the AssemblyInfo.vb file. I have managed to get the AssemblyDescription and AssemblyVersion out...but can't seem to figure out how to get anything else out (for example: AssemblyTitle, AssemblyCompany, & AssemblyCopyright)

I didn't create any custom fields...just used what was there already.

Any suggestions?

Thanks in advance!

MKoslof
06-29-2004, 02:42 PM
Well, if you want to extract the project's assembly info, use a class. Here is one that I use :



Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices


Module ShowAssemblyDemo

Public Class return_Assembly_Info
Private myType As Type

Public Sub New()
myType = GetType(MainMenu)
End Sub

Public ReadOnly Property AsmName() As String
Get
Return myType.Assembly.GetName.Name.ToString()
End Get
End Property
Public ReadOnly Property AsmFQName() As String
Get
Return myType.Assembly.GetName.FullName.ToString()
End Get
End Property
Public ReadOnly Property CodeBase() As String
Get
Return myType.Assembly.CodeBase
End Get
End Property
Public ReadOnly Property Copyright() As String
Get
Dim at As Type = GetType(AssemblyCopyrightAttribute)
Dim r() As Object = myType.Assembly.GetCustomAttributes(at, False)
Dim ct As AssemblyCopyrightAttribute = CType(r(0), AssemblyCopyrightAttribute)
Return ct.Copyright
End Get
End Property
Public ReadOnly Property Company() As String
Get
Dim at As Type = GetType(AssemblyCompanyAttribute)
Dim r() As Object = myType.Assembly.GetCustomAttributes(at, False)
Dim ct As AssemblyCompanyAttribute = CType(r(0), AssemblyCompanyAttribute)
Return ct.Company
End Get
End Property
Public ReadOnly Property Description() As String
Get
Dim at As Type = GetType(AssemblyDescriptionAttribute)
Dim r() As Object = myType.Assembly.GetCustomAttributes(at, False)
Dim da As AssemblyDescriptionAttribute = CType(r(0), AssemblyDescriptionAttribute)
Return da.Description
End Get
End Property
Public ReadOnly Property Product() As String
Get
Dim at As Type = GetType(AssemblyProductAttribute)
Dim r() As Object = myType.Assembly.GetCustomAttributes(at, False)
Dim pt As AssemblyProductAttribute = CType(r(0), AssemblyProductAttribute)
Return pt.Product
End Get
End Property
Public ReadOnly Property Title() As String
Get
Dim at As Type = GetType(AssemblyTitleAttribute)
Dim r() As Object = myType.Assembly.GetCustomAttributes(at, False)
Dim ta As AssemblyTitleAttribute = CType(r(0), AssemblyTitleAttribute)
Return ta.Title
End Get
End Property
Public ReadOnly Property Version() As String
Get
Return myType.Assembly.GetName.Version.ToString()
End Get
End Property
End Class

Fateseer
06-29-2004, 04:14 PM
That did the trick!

Now I just have to go through it and make sure I understand it all! ;)
Then I might just be ready for some custom fields!

Thanks a lot!

MKoslof
06-29-2004, 04:16 PM
That's great news. Glad to help. Post again if you run into more trouble.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum