加载和装配没有锁定文件的执行code?加载、文件、code

2023-09-07 08:41:47 作者:一个人不够不够不够°

有没有办法从磁盘加载程序集,并没有得到锁定在磁盘上的文件再执行code?我永远无法理解为什么必须锁定文件,因为code将在RAM中加载和JIT编译的?

Is there a way to load an assembly from disk and execute code in it without getting the file locked on disk? I never understood why it is necessary to lock the file since the code will be loaded in RAM and JIT-compiled?

推荐答案

这是可能的,你可以使用的的Assembly.Load(byte []的)以加载程序集,以及。该程序集不具有加载上下文,可以反复加载它。管理这可是不容易的,你一定会找到答案。

It's possible, you can use Assembly.Load(byte[]) to load an assembly as well. That assembly doesn't have a "loading context", you can load it repeatedly. Managing this is however not easy, you're bound to find out.