Av rating:
Total votes: 15
Total comments: 1


Jason Crease
First Steps with .NET Reflector
17 November 2008

If you are new to using NET Reflector, or you are wondering whether it would be useful to you, you'll appreciate Jason Crease's quick run through of the basic functionality.  This is also available as a video here

When you first run .NET Reflector, you will be asked pick a version of the NET Framework to populate the assembly list.

When you want to browse an assembly, all you will need to do is to run NET Reflector, drag the file from Windows explorer and drop it onto NET Reflector. You can also open and .exe, .dll or .mcl file from the file menu in .NET Reflector.

Then you can drill down into namespaces, class and functions and down there, you have a bit of information about each of the components – you can see where the assembly is, its name, version, what type of assembly it is…

Here, we are browsing System.Windows.Forms

The main functionality of .NET Reflector is the disassembler. So let’s say I want to understand what happens during a particular event because something is not behaving the right way, or my app is not behaving as expected. You can drill down to the method of your choice, right-click and choose Disassemble. And there you have it:

You may, at this stage, need to choose the version of NET Framework  that the assembly was developed with by using the View->options dialog box.

you can see the code for that function and see what it does in the Disassembler pane on the right.

I can choose to view the code in C#, or VB.NET or IL code.

The other cool thing you can do with .NET Reflector is navigating the code view. You can browse the source code by clicking on a function name and that’s really useful because you can explore code quickly, and understand what’s happening behind the scenes.

You can navigate the disassembly view,so if I click here in the onclick method


... it will take me to method OnClick

 

Right down there, we can see that we have the ability to Expand Methods.

When we click on it, it expands and decompiles all the methods in one go.

The other thing you can do with .NET Reflector, is to Analyze a class or a function, so say we pick the function called OnClick(EventArgs) and we right click and choose the command Analyze, we’ll have the Analyzer come up here on the right and we can see what that function depends on, and see the functions that it uses…so we can see the interaction between the different functions.

It’s the same principle with a Class. If you pick a class, say Button, you can see the same thing plus, we can also see what the type is exposed by and instantiated by.

You can also access documentation with .NET Reflector. So if I pick an assembly for which there’s xml documentation available, we can see the documentation for that class or function appearing down on the right. Here we’ll look at a class from ANTS Profiler.

 .NET Reflector also has a search functionality (<View<Search). You can set it so it searches on classes or functions.

You’ll also note that .NET Reflector lets you access and save resource files.

Finally, one last thing I wanted to show you is the Windows Shell integration. We’ll close Reflector, bring up the command line (run – cmd), we’ll drag the Reflector.exe in here and add “ /register”

Now if we find a dll and right-click on it, we get a “Browse with .NET Reflector” in the context menu!

If you press Control Alt C when you have selected an item in an assembly in NET Reflector’s browser, you will have a reference on your clipboard that is just like a URL. If you paste it into any web-page or browser-based page, you can then use the URI as a short-cut to bring that item up in NET Reflector.



This article has been viewed 1343 times.
Jason Crease

Author profile: Jason Crease

Jason Crease studied maths and computer Science at Cambridge University and joined Red-Gate two years ago as a Test Engineer. He specialises in Testing .NET applications and is part of the team responsible for the development of ANTS Profiler and .NET Reflector

Search for other articles by Jason Crease

Rate this article:   Avg rating: from a total of 15 votes.


Poor

OK

Good

Great

Must read
 
Have Your Say
Do you have an opinion on this article? Then add your comment below:
You must be logged in to post to this forum

Click here to log in.


Subject: Anonymous commenting disabled
Posted by: Chris Massey (view profile)
Posted on: Friday, January 02, 2009 at 6:56 AM
Message: Anonymous commented has been disabled on this article, due to spamming. If you want to leave a comment, you'll have to sign in or sign up. Sorry for any inconvenience.

 






recommended site pinvoke

PInvoke.net is a user-driven wiki which provides .NET developers with native method signatures, so they don't have to spend time writing them from scratch.





Damon Armstrong
Customizing the Login Page in SharePoint 2007
 Damon shows how a few simple steps lead you to being able to include the login form in a consistent look and feel to...  Read more...


ANTS Profiler and the Un-Rest Cure
 After a while, successful applications can get set in their ways. Bart Read and Andrew Hunter decided... Read more...

Silverlight-Speed Loop
 John Bower steps up a gear, produces a Lamborghini, and examines the process of using a high-speed... Read more...

Sid: Vicious
 Dan Archer documents his epic struggle with an apparently simple task of authenticating user... Read more...

Embedding Help so it will be used
 It is not good enough to make assumptions about the way that users go about getting help when they use... Read more...

Software Tool Design: Design by Sketching
 Developers can get so used to relying on computers for everything that they can forget how useful it... Read more...

A Complete URL Rewriting Solution for ASP.NET 2.0
 Ever wondered whether it's possible to create neater URLS, free of bulky Query String parameters?... Read more...

.NET Application Architecture: the Data Access Layer
 Find out how to design a robust data access layer for your .NET applications. Read more...

Web Parts in ASP.NET 2.0
 Most Web Parts implementations allow users to create a single portal page where they can personalize... Read more...

Visual Studio Setup - projects and custom actions
 This article describes the kinds of custom actions that can be used in your Visual Studio setup project. Read more...

Beginning ASP.NET 2.0
 It seems that there is both excitement and confusion surrounding Master Pages and Themes. A big part of... Read more...

Over 150,000 Microsoft professionals subscribe to the Simple-Talk technical journal. Join today, it's fast, simple, free and secure.

Join Simple Talk