如何保存大会类的对象到磁盘.NET磁盘、对象、大会、NET

2023-09-05 01:29:33 作者:捂著心脏、逞強旳笑

我有assemvly EN coded到Base64的字符串在磁盘上。 它需要它的DLL重presentation。我可以加载到Assembly对象, 但找不到方法来保存它。谢谢!

I have assemvly encoded into Base64 string on disk. It's needed it dll representation. I can load it into Assembly object, but could not find way to save it. Thanks!

那么,1)如何保存大会类到磁盘的对象呢?     2)如何保存的base64 EN codeD组装成二进制的dll? [回答]

So, 1) how to save object of the Assembly class to disk? 2) how to save base64 encoded assembly to binary dll? [answered]

推荐答案

只是把它作为二进制 - 因此,使用 Convert.FromBase64String 获得字节[] ,写的是:

Just treat it as binary - So use Convert.FromBase64String to get a byte[], and write that:

string base64 = File.ReadAllText(base64path);
byte[] binary = Convert.FromBase64String(base64);
File.WriteAllBytes(binaryPath, binary);

有关信息,在运行时对象的条件; AssemblyBuilder 有一个 .Save(...);但组装不会。

For info, in terms of runtime objects; AssemblyBuilder has a .Save(...); but Assembly does not.