Ramblings & Controls from a .NET Addicted Freak!

Kevin Gearing's Blog

August 2004 - Posts

  • Displaying a List of Referenced Assemblies

    Yet another post on ideas for 'About' windows...

    Having a list of assemblies displayed that your application references can be helpful in determining problems with your application due to version inconsistencies etc. By adding a listview to your window and making use of code similar to the below you can easily display the name and version of all assemblies referenced by your application.

    Imports System.Reflection

    Private Sub PopulateListView()

    'Get a list of referenced assemblies

    Dim assemblyNames() As System.Reflection.AssemblyName = [Assembly].GetExecutingAssembly.GetReferencedAssemblies

    Dim assemblyName As System.Reflection.AssemblyName

    Dim listViewItem As System.Windows.Forms.ListViewItem

    Dim i As Integer

    'Add each assemblies information to the listview

    For i = assemblyNames.GetLowerBound(0) To assemblyNames.GetUpperBound(0)

    assemblyName = CType(assemblyNames.GetValue(i), System.Reflection.AssemblyName)

    listViewItem = New System.Windows.Forms.ListViewItem

    listViewItem.Text = assemblyName.Name

    listViewItem.SubItems(1).Text = assemblyName.Version.ToString


    Next i

    End Sub

Copyright ©2004-2007 Kevin Gearing. All Rights Reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems