Reader Level:
Articles

Unloading Assemblies in C#

By Ibrahim Ersoy on July 08, 2012
This article shows how to unload assemblies.
  • 0
  • 0
  • 6960

If you've created an Application Domain and want to unload all the assemblies loaded within, there is no way to unload Assembly themselves. But you can unload Application Domain you've just created.

In addition to that one;

You cannot unload the default Application Domain CLR created on its own. And unloading can differ from the assemblies being used and the unload events these assemblies have. It can take some time.

To Unload an Application Domain all you need to do is calling Unload function.

A sample code can help you understand:

AppDomain myDom=AppDomain.Create("Ibrahims Domain");

//Here assuming you loaded your assemblies
//To unload AppDomain call Unload Function

AppDomain.Unload(myDom);

// The Application Domain we've just created is now no more as the assemblies with it.

After Unloading Application Domain object, we've also unloaded all the assemblies loaded within.

Ibrahim Ersoy

Ibrahim Ersoy lives in Turkey, Istanbul. He helps running and managing C# Corner. He is a Software Consultant (Sharepoint) and MindCracker MVP. He writes about cutting-edge Microsoft Technologies including XNA,... Read more

Personal Blog: http://www.iersoy.com
COMMENT USING

Trending up