I am trying to save an Assembly to a file using System.Reflection.Emit.AssemblyBuilder but it’s not working.
I’ve got a variable to hold an assembly that is running perfect when I load and run it.
System.Reflection.Assembly dll = GetAssembly(resource);
Is there anyone who can help me to save this “dll” into a file like “name.dll”?
In the comments, you’ve said that the private
GetAssemblymethod fetches data from a resource file and builds an assembly from it. Assuming the “bytes” it’s getting from the resource file really are just the bytes of the assembly, the simplest way of getting a file is to get those same bytes from the resource file, and callFile.WriteAllBytes. You don’t need to go via anAssemblyobject, and doing so makes the job harder.