We pay for user submitted tutorials and articles that we publish. Anyone can send in a contributionLearn More
If you are a .NET developer, you should probably know the .NET Reflector which is a great tool for viewing, navigating and searching through the class hierarchies of .NET assemblies (even if you don’t have the code for them). I am using this tool a lot but here is something I only recently discovered: one can export an assembly and let the Reflector generate its source code. The output of this process is a directory with a project file and all of the source files.
Lets deep dive into this process. The first thing to do is to drag the assembly you’re interested in into the Reflector. I want to show my case on the XHTML sitemap validation tool dll, which can be downloaded from our Freebies page. The next step is to right click on this assembly and choose the Export menu option:
Now, you shall provide the output directory where the generated code will reside, and click Start:
Here we go, the code generation begins:
During this process, the Reflector may need some user interventions to help it find some of the generated assembly dependencies. If it happens, the following screen will pop up:
The text box may be empty if the Reflector has no clue about the dependency file location, or it may contain some location which is suggested by the Reflector. Provide the correct location and press OK. When the code generation is completed, click the Close button and go to the output directory to see what you got.
Open the project file, let Visual Studio convert it and try to compile. Being honest, you will be lucky if the code is compiled at the first try because there are some issues with this Export process. As for what I know, there might be problems generating:
There might be more problems, but you can easily fix all of the compilation errors by yourselves. Now, just for fun, try to do this whole process for the reflector.exe! Sadly, when looking at the generated code, you realize that the Reflector fails to generate its own source code… Or maybe its intended?
Tags :.NetassemblyexportgenerateReflectorreverse engineeringsource code
Copyright © 2012 Dev102.com
Breeze : Designed by Amit Raz and Nitzan Kupererd