Question

I need to get CLR version that my assembly requires and remove the assembly afterwards. Each of those separately is trivial, but if I want to do both of them I run into problems: to get the value of ImageRuntimeVersion property I need to load the assembly. This prevents me from deleting the file as it says the file is in use. I tried to load that file in a separate appdomain, but failed miserably (eg. got some errors that the file could not be found even if I loaded it using constructor that takes byte[] as argument or another error: SecurityException saying something about RegistryPermission).

No correct solution

OTHER TIPS

Could you just read the assembly into a memory stream and load that? It should save you from locking the the original assembly but I've seen from other comments this will cause any linked assemblies to lock.

Then the assembly you want to delete is just a disconnected file so after you've disposed of it after reading it in, you should be able to delete it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top