Search code examples
c#.netdynamicassemblybuilder

Dynamically created class to cs file?


I am creating a complex class with AssemblyBuilder that Im later creating objects from. There is however uncertainties in how this class is really contructed. So is there any way to write this dynamicly created class to a cs file for inspection?

I can get the dll file written to disk but I need the cs file.


Solution

  • You can decompile managed .NET dll to C# code using

    • DotPeek by JetBrains (free, sources are closed)
    • ILSpy open source project (MIT license sources are available at github)
    • Reflector by Red Gates (Paid tool, sources are closed)
    • JustDecompile by Telerik (free with open source decompilation engine available at github Apache License)
    • There is also a Microsoft's ildasm tool.

    If you need to write custom tool you can download open-source code and give it a try.