How to load an assembly without using Assembly.Load?

后端 未结 4 680
时光说笑
时光说笑 2020-12-29 17:03

Is it possible to do this by streaming the assembly into memory? If so, how does one do this?

Reason:

I don\'t want to lock the dll that\'s loaded. I want to

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 17:51

    It can be done by an overload of Load using byte array. You need to read the assembly bytes before the load and it won't lock the file:

    byte[] readAllBytes = File.ReadAllBytes("path");
    Assembly assembly = Assembly.Load(readAllBytes);
    

提交回复
热议问题