Get Assembly Info (Assembly)
Retrieves descriptive metadata from the specified Reflection.Assembly,
The function uses the function GetAssemblyPlatform to retrieve the target platform and GetFrameworkInfo to retrieve the target Framework.
The function return a tuple containing:
- Product: The product name defined in the assembly.
- Version: The file version of the assembly.
- Copyright: The copyright text.
- Company: The name of the company that produced the assembly.
- Platform: The target platform (e.g., (AnyCPU), (x64), (x86)).
- Framework: The .NET framework version targeted by the assembly.
- Description: The description text of the assembly.
If the file does not exist or an error occurs, all values are returned as empty strings.
VB
Public Function GetAssemblyInfo(assembly As Assembly) As
(Product As String,
Version As String,
Copyright As String,
Company As String,
Platform As String,
Framework As String,
Description As String)
Dim Product As String = String.Empty
Dim Version As String = String.Empty
Dim Copyright As String = String.Empty
Dim Company As String = String.Empty
Dim Platform As String = String.Empty
Dim Framework As String = String.Empty
Dim Description As String = String.Empty
If Not assembly Is Nothing Then
Try
Product = CType(assembly.GetCustomAttribute(GetType(AssemblyProductAttribute)), AssemblyProductAttribute).Product
Version = CType(assembly.GetCustomAttribute(GetType(AssemblyFileVersionAttribute)), AssemblyFileVersionAttribute).Version
Company = CType(assembly.GetCustomAttribute(GetType(AssemblyCompanyAttribute)), AssemblyCompanyAttribute).Company
Copyright = CType(assembly.GetCustomAttribute(GetType(AssemblyCopyrightAttribute)), AssemblyCopyrightAttribute).Copyright
Description = CType(assembly.GetCustomAttribute(GetType(AssemblyDescriptionAttribute)), AssemblyDescriptionAttribute).Description
Platform = GetAssemblyPlatform(assembly)
Framework = GetFrameworkInfo(assembly)
Catch ex As Exception
Product = String.Empty
Version = String.Empty
Copyright = String.Empty
Company = String.Empty
Platform = String.Empty
Framework = String.Empty
Description = String.Empty
End Try
End If
Return (Product, Version, Copyright, Company, Platform, Framework, Description)
End Function