組裝我想Reflection.Emit
在內存中創建
目前在內存中創建一個組件,使用使用類的,我可以創建裝配並獲得它的使用的東西字節像
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 ...
}
但是,它通過在本地文件系統上創建文件來實現。我實際上並不需要該文件,只需要文件中的字節。
是否可以在不寫任何文件的情況下創建程序集?