Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / April 2005

Tip: Looking for answers? Try searching our database.

Detailed Information about members of an assembly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nimit - 26 Apr 2005 09:58 GMT
Hi,
Can anyone please tell me how to retreive the detailed information of
members of an Assembly.(As in summary column when one selects a member
within an assembly in an OBJECT BROWSER, in the .net IDE ).
Thanks,
Nimit.
Herfried K. Wagner [MVP] - 26 Apr 2005 10:38 GMT
"Nimit" <nimitsharma16@gmail.com> schrieb:
> Can anyone please tell me how to retreive the detailed information of
> members of an Assembly.(As in summary column when one selects a member
> within an assembly in an OBJECT BROWSER, in the .net IDE ).

Take a look at the 'System.Reflection' namespace and the 'Type' class.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Bob Powell [MVP] - 26 Apr 2005 11:18 GMT
The process is called reflection. This reads metadata stored in the assembly
that describes the classes and members.
After my signature there is a simple application that demonstrates this.
Click the button and load any .NET exe or DLL.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

using System;

using System.Reflection;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

namespace reflectasm

{

/// <summary>

/// Summary description for Form1.

/// </summary>

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.Button button1;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.textBox1 = new System.Windows.Forms.TextBox();

this.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// textBox1

//

this.textBox1.Location = new System.Drawing.Point(8, 8);

this.textBox1.Multiline = true;

this.textBox1.Name = "textBox1";

this.textBox1.Size = new System.Drawing.Size(360, 400);

this.textBox1.TabIndex = 0;

this.textBox1.Text = "textBox1";

//

// button1

//

this.button1.Location = new System.Drawing.Point(400, 360);

this.button1.Name = "button1";

this.button1.TabIndex = 1;

this.button1.Text = "button1";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(496, 414);

this.Controls.Add(this.button1);

this.Controls.Add(this.textBox1);

this.Name = "Form1";

this.Text = "Form1";

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void button1_Click(object sender, System.EventArgs e)

{

OpenFileDialog dlg=new OpenFileDialog();

if(dlg.ShowDialog()==DialogResult.OK)

{

Assembly a=Assembly.LoadFile(dlg.FileName);

foreach(Type t in a.GetTypes())

{

this.textBox1.Text+=t.FullName+"...\r\n";

foreach(MemberInfo mi in t.GetMembers())

{

this.textBox1.Text+="member "+mi.Name+" is a
"+mi.MemberType.ToString()+"\r\n";

}

}

}

}

}

}

> Hi,
> Can anyone please tell me how to retreive the detailed information of
> members of an Assembly.(As in summary column when one selects a member
> within an assembly in an OBJECT BROWSER, in the .net IDE ).
> Thanks,
> Nimit.
Nimit Sharma - 27 Apr 2005 06:46 GMT
Nimit Sharma - 27 Apr 2005 06:53 GMT
Hi Bob Powell....

Thanks for looking out for my problem..but its not solved as
yet....using..

foreach(MemberInfo mi in t.GetMembers())
{
this.textBox1.Text+="member "+mi.Name+" is a
"+mi.MemberType.ToString()+"\r\n";
}

we can only get the names/types of the respected members....but what if
one wants the specific information such as access specifiers, return
types etc of constructors,events, properties etc.....
I want the detailed information of the respective type as seen in the
Summary field (when we click on a particular member of an assembly in
the OBJECT BROWSER of .NET IDE) .

Kindly reply...
Nimit Sharma...
Bob Powell [MVP] - 27 Apr 2005 10:24 GMT
That information is only a selected few properties of the MemberInfo class.
Examine that class and the others derived from it such as PropertyInfo etc
and you'll see that the info you want is all in there.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> Hi Bob Powell....
>
[quoted text clipped - 18 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.