{"id":472,"date":"2008-11-17T00:00:00","date_gmt":"2008-11-17T00:00:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/first-steps-with-net-reflector\/"},"modified":"2021-05-11T15:56:43","modified_gmt":"2021-05-11T15:56:43","slug":"first-steps-with-net-reflector","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/development\/dotnet-development\/first-steps-with-net-reflector\/","title":{"rendered":"First Steps with .NET Reflector"},"content":{"rendered":"<div id=\"pretty\">\n<p>When you first run .NET Reflector, you will be asked pick a version of the NET Framework to populate the assembly list.  <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"260\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image000.jpg\" width=\"317\" alt=\"602-image000.jpg\" \/><\/p>\n<p>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 <b>.exe<\/b>, <b>.dll <\/b>or <b>.mcl <\/b>file from the file menu in .NET Reflector.  <\/p>\n<p>Then you can drill down into namespaces, class and functions and down there, you have a bit of information about each of the components &#8211; you can see where the assembly is, its name, version, what type of assembly it is&#8230;<\/p>\n<p>Here, we are browsing <b>System.Windows.Forms<\/b><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"766\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image002.jpg\" width=\"383\" alt=\"602-image002.jpg\" \/><\/p>\n<p>The main functionality of .NET Reflector is the disassembler. So let&#8217;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 <b>Disassemble<\/b>. And there you have it: <\/p>\n<\/p>\n<p>You may, at this stage, need to choose the version of NET Framework&#160; that the assembly was developed with by using the <i>View-&gt;options <\/i>dialog box. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"325\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image001.jpg\" width=\"406\" alt=\"602-image001.jpg\" \/><\/p>\n<p>you can see the code for that function and see what it does in the Disassembler pane on the right.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"457\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image005.jpg\" width=\"579\" alt=\"602-image005.jpg\" \/><\/p>\n<p>I can choose to view the code in C#, or VB.NET or IL code.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"457\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image0055.jpg\" width=\"579\" alt=\"602-image0055.jpg\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"147\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-OnclickDetail.jpg\" width=\"297\" class=\"float-right\" alt=\"602-OnclickDetail.jpg\" \/><\/p>\n<p>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&#8217;s really useful because you can explore code quickly, and understand what&#8217;s happening behind the scenes.<\/p>\n<p>You can navigate the disassembly view,so if I click here in the onclick method<\/p>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"103\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-Onclickmethod.jpg\" width=\"290\" class=\"float-right\" alt=\"602-Onclickmethod.jpg\" \/><\/p>\n<p>&#8230; it will take me to method <b>OnClick<\/b><\/p>\n<p>Right down there, we can see that we have the ability to Expand Methods. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"601\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image008.jpg\" width=\"553\" alt=\"602-image008.jpg\" \/><\/p>\n<p>When we click on it, it expands and decompiles all the methods in one go.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"601\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image010.jpg\" width=\"553\" alt=\"602-image010.jpg\" \/><\/p>\n<p>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&#8217;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&#8230;so we can see the interaction between the different functions.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"624\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image012.jpg\" width=\"553\" alt=\"602-image012.jpg\" \/><\/p>\n<p>It&#8217;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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"624\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image014.jpg\" width=\"553\" alt=\"602-image014.jpg\" \/><\/p>\n<p>You can also access documentation with .NET Reflector. So if I pick an assembly for which there&#8217;s xml documentation available, we can see the documentation for that class or function appearing down on the right. Here we&#8217;ll look at a class from ANTS Profiler.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"456\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image016.jpg\" width=\"553\" alt=\"602-image016.jpg\" \/><\/p>\n<p>&#160;.NET Reflector also has a search functionality (<i>&lt;View&lt;Search<\/i>). You can set it so it searches on classes or functions.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"509\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image018.jpg\" width=\"553\" alt=\"602-image018.jpg\" \/><\/p>\n<p class=\"MsoNormal\">You&#8217;ll also note that .NET Reflector lets you access and save resource files.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"578\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image020.jpg\" width=\"554\" alt=\"602-image020.jpg\" \/><\/p>\n<p>Finally, one last thing I wanted to show you is the Windows Shell integration. We&#8217;ll close Reflector, bring up the command line (run &#8211; cmd), we&#8217;ll drag the Reflector.exe in here and add &#8221; \/register&#8221; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"315\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image022.jpg\" width=\"554\" alt=\"602-image022.jpg\" \/><\/p>\n<p>Now if we find a dll and right-click on it, we get a &#8220;Browse with .NET Reflector&#8221; in the context menu!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" height=\"339\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/602-image024.jpg\" width=\"453\" alt=\"602-image024.jpg\" \/><\/p>\n<p>If you press Control Alt C when you have selected an item in an assembly in NET Reflector&#8217;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.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you are new to using .NET Reflector, or you are wondering whether it would be useful to you, you&#8217;ll appreciate Jason Crease&#8217;s quick run through of the basic functionality.  This is also available as a video.<br \/>\n&hellip;<\/p>\n","protected":false},"author":95472,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143538],"tags":[4143,4204,4885],"coauthors":[],"class_list":["post-472","post","type-post","status-publish","format-standard","hentry","category-dotnet-development","tag-net","tag-net-tools","tag-reflector"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/95472"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=472"}],"version-history":[{"count":4,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/472\/revisions"}],"predecessor-version":[{"id":90938,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/472\/revisions\/90938"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=472"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}