3

How can I unload a DLL from memory that belongs to another process, or the process had ended but the DLL is still loaded into memory?

I know how to find an existing process and even list all the loaded DLL's for that, but what I can't seem to get is how to find loaded DLL's and unload them from memory.

Everything I've read talks about AppDomains, but I'm not sure if this case would apply or not to that method since I want to close DLL's that aren't called by my app.

Any help would be appreciated.

DanM7
  • 2,203
  • 3
  • 28
  • 46
  • To do that i used MAF, you can read more about MAF [here][1] [1]: http://stackoverflow.com/questions/835182/choosing-between-mef-and-maf-system-addin – ígor Oct 23 '12 at 18:14

2 Answers2

1

I don't think you can unload a single assembly. But you can unload an AppDomain that contains the assembly.

Science_Fiction
  • 3,403
  • 23
  • 27
0

A shared DLL loaded in domain neutral manner cannot be unloaded unless the Process is exited. Domain specific DLLs are unloaded alongwith Domain. There is however no way to unload individual DLLs even if the DLL has been loaded for reflection only.

jags
  • 2,022
  • 26
  • 34
  • so even if the process that loaded the dll in the first place has exited i can't unload an dll's that didn't unload when the app closed/crashed? – user1769189 Oct 23 '12 at 18:53
  • Are you using DLL across multiple application domains in same process or across multiple processes? If the DLL has been loaded in shared mode, it will not unload unless all AppDomains unload. – jags Oct 23 '12 at 19:09