Problem Statement
I'm implementing some sort of a Shadow Copy in C# when loading dll, to prevent the dll file from being locked. It works as follows:
- Say I have sample.dll and want to load it into the appdomain without locking it
- First I make a copy of the assembly with the name sample_shadow.dll in the same directory
- Then I load sample_shadow.dll with Assembly.Load (Assembly.LoadFrom and AssemblyName.GetAssemblyName are also tried)
- After that, the loaded assembly appears to have a base location of sample.dll instead of sample_shadow.dll, and sample.dll is locked
Questions
- I'd like to know how can I load sample_shadow.dll correctly and thus prevent sample.dll to be locked
- I'd appreciate very much if someone can elaborate on the mechanisms in the background
Thanks in advance!
P.S. To load assembly with bytes is not an option due to the use of multiple dll and static variables (I think the load-bytes version missed some information compared to the load-with-file-name version of Assembly.Load)
Aucun commentaire:
Enregistrer un commentaire