I would like to create an assembly in memory using classes in Reflection.Emit
Currently, I can create an assembly and get its bytes using something like
AssemblyBuilder builder =
AppDomain.CurrentDomain.DefineDynamicAssembly(...,
AssemblyBuilderAccess.Save);
... create the assembly ...
builder.Save(targetFileName);
using(FileStream fs = File.Open(targetFileName, FileMode.Open))
{
... read the bytes from the file stream ...
}
However, he does this by creating a file on the local file system. I really don't need the file, just the bytes that will be in the file.
Is it possible to create an assembly without writing any files?
source
share