Get list of Loaded Assesmlies

This method will enumerate and list all currently loaded assemblies into
the adjacent list box. Listed assemblies can subsequently be clicked on
to display further details.


private void cmdListLoadedAssemblies_Click(object sender, System.EventArgs e)
{
Assembly[] asms;

//Retrieve the loaded assemblies from the current AppDomain.
asms = AppDomain.CurrentDomain.GetAssemblies();

//Clear out any current listbox entries
lstLoadedAssemblies.Items.Clear();

//Enumerate and display the assemblies
foreach(Assembly asm in asms)
{
lstLoadedAssemblies.Items.Add(asm.GetName().Name);
}

this.UpdatePanels(this.lstLoadedAssemblies.Items.Count);

//if there are assemblies listed, allow viewing of details
cmdAssemblyDetail.Enabled = (lstLoadedAssemblies.Items.Count > 0);

//Clear out previous details
txtDisplayName.Text = string.Empty;
txtLocation.Text = string.Empty;
lstTypes.Items.Clear();
lstMembers.Items.Clear();
CurrentAsm = null;
}


The following three overloaded methods (UpdatePanels) update the status bar's three panels text with the count of the loaded assemblies, types, and members respectively.


private void UpdatePanels(int AsmCount)
{
UpdatePanels(AsmCount, 0);
}

private void UpdatePanels(int AsmCount, int TypeCount)
{
UpdatePanels(AsmCount, TypeCount, 0);
}

private void UpdatePanels(int AsmCount, int TypeCount, int MethodCount)
{
StatusBarPanel pAsm = this.sbInfo.Panels[0];
StatusBarPanel pTyp = this.sbInfo.Panels[1];
StatusBarPanel pMbr = this.sbInfo.Panels[2];
const string ASM_TEXT = "Assemblies: {0}";
const string TYP_TEXT = "Types: {0}";
const string MBR_TEXT = "Members: {0}";
pAsm.Text = string.Format(ASM_TEXT, AsmCount.ToString());
pTyp.Text = string.Format(TYP_TEXT, TypeCount.ToString());
pMbr.Text = string.Format(MBR_TEXT, MethodCount.ToString());
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: