I am generate assembly object in memory and need to get it byte representation.
I’ve following code but today I need that it to be done in memory
var assembly = GetMyAssembly();
var binary = File.ReadAllBytes(assembly.Location);
I’ve looked into Assembly builder methods and Assembly methods but can’t find appropriate methods.
Thanks.
This is not possible in the runtime.
The only possible solution is to use WinDbg and SOS to dump the assembly. But then again, all my attempts at doing that exact same thing has failed.