Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unload a .NET assembly reference in IronPython

After loading a reference to an assembly with something like:

import clr
clr.AddRferenceToFileAndPath(r'C:\foo.dll')

How can I unload the assembly again?

Why would anyone ever want to do this? Because I'm recompiling foo.dll and want to reload it, but the compiler is giving me a fuss, since IronPython is allready accessing foo.dll.

like image 667
Daren Thomas Avatar asked Sep 01 '09 12:09

Daren Thomas


1 Answers

.NET itself doesn't support unloading just a single assembly. Instead, you need to unload a whole AppDomain. I don't know exactly how IronPython works with AppDomains, but that's the normal .NET way of doing things. (Load the assembly into a new AppDomain, use it, discard the AppDomain, create a new AppDomain with the new version of the file etc.)

like image 120
Jon Skeet Avatar answered Sep 26 '22 09:09

Jon Skeet