I’m working on a project that involves researching and comparing many versions of the same DLL. I don’t have the source for every version of this DLL so I needed a way to convert it to C# files and diff those. Since there are thousands of versions of this file out there I needed to be able to generate the C# files programmatically.
I started with Reflector, but it doesn’t have a simple API needed to generate the files programmatically.
I came across [JustDecompile](http://www.telerik.com/products/decompiler.aspx. from Telerik and found that they do have a command line API that works great. I could have just invoked the EXE with Process.Start, but I figured I should see how they are doing and see if I could do everything inproc. So I decompiled the JustDecompile.exe file and found a very simple DLL method that they use to output C# files.
1. Download JustDecompile
2. Open up your project and Add References to these two DLLs.
3. Add the following namespaces:
4. Add this code to your project where you want to programmatically decompile code
Where [path to dll] is the path to the dll that you want to decompile and outfolder is the folder you want to output the C# files.
5. Add this event handler to be notified when the Visual Studio Project file has been created
Hope this saves you some time.