12

If I do an Assembly.ReflectionOnlyLoadFrom(), is it possible to unload the assembly?

Or, can it be unloaded only if it is in a separate AppDomain, as with Assembly.LoadFrom() ?

I have a tool that needs to load an assembly for inspection.

Pierre Arnaud
  • 10,212
  • 11
  • 77
  • 108
Cheeso
  • 189,189
  • 101
  • 473
  • 713

2 Answers2

10

Yes, you need to load it into a separate AppDomain, then unload the entire AppDomain.

Steven Sudit
  • 19,391
  • 1
  • 51
  • 53
0

You can create an instance in the new AppDomain and execute your code in that instance. Please see full example here: https://stackoverflow.com/a/37970043/797249

Community
  • 1
  • 1
Artiom
  • 7,694
  • 3
  • 38
  • 45