【发布时间】:2020-06-24 09:06:57
【问题描述】:
您好,我目前正在尝试解决有关我正在开发的软件的问题。
我想要实现的目标:从没有 WriteAllBytes 的 byte[] 将 dll 加载到内存流中(这意味着我想避免接触磁盘)。
我尝试了很多方法,但都失败了。我认为我成功地将 byte[] 加载到内存中,但是我编译的可执行文件仍在寻找从磁盘而不是内存加载它。如何让它从内存中加载以便能够使用?
让我们进入代码。
WebClient client = new WebClient();
string b64strbin = client.DownloadString("URL OF A FILE WHERE IT CONTAINS BYTE[]"); // this will download the string and store it to a variable.
byte[] decode = Convert.FromBase64String(b64strbin); // just decode it from base64 back to byte[]
byte[] packed = QuickLZ.decompress(decode); // decompressed dll byte[] (dont mind about this)
Assembly.Load(packed); // here i am loading the byte[] to the memory but still i get an exception
//methods that require the dll in order to run
Console.Read();
【问题讨论】:
-
您尝试加载的程序集引用了您的应用找不到的
BouncyCastle.Crypto程序集。您必须手动处理参考分辨率。 -
嗯,因为我是 C# 新手,你能提供一个例子或任何我可以阅读的参考网站吗?
-
@0xyg3n 你能用 nuget prackge 吗?
-
不,我不能将我正在使用的项目用于 CodeDOM 运行时编译,我不知道如何在运行时编译器上使用 nuget。如果你这样做,我相信会解决我的大部分问题。
-
digitallycreated.net/Blog/61/… 这看起来我得到了一些进一步调查..
标签: c# memory dll managed assembly.load