Get list of loaded assemblies

Posted by Bubbly under C# category on | Views : 3296
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

//Enumerate and display the assemblies
foreach(Assembly asm in asms)


//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;
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 or Responses

Login to post response