.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Get list of Loaded Assemblies

Posted By:Deepika Haridas       Posted Date: October 08, 2009    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

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());


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend