Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 23832, Unload .Net Assemblies

by Bruce McGee Email: Anonymous


Example of dynamically loading and then unloading a .Net assembly.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 10.0  to 10.0 93 downloads
Copyright: No significant restrictions


Size: 16,603 bytes
Updated on Sat, 12 Nov 2005 22:14:35 GMT
Originally uploaded on Sun, 06 Nov 2005 03:32:26 GMT
SHA1 Hash: D276641D3084B1A0706C9EAF4AE49AC2FEBF6895
MD5 Hash: 382D5C96B7F7A9AB0458CA89D92B087D

    Explore the files in this upload

Description
Loading assemblies in .Net is pretty straight forward and gives you access to the assembly's functionality and all of its metadata.

Unfortunately, unloading them isn't as simple. The Assembly class doesn't have an Unload method, so anything you load stays loaded until the application ends.

You can unload Application Domains, though. And Application Domains can load their own assemblies. Unfortunately, if you use these assemblies directly, they are also loaded in to the default Application Domain, where they stay until the application ends.

I found the answer in the Under Construction article by Bob Swart in the February 2005 issus of The Delphi Magazine. You have to create a separate Application Domain that instantiates a class that you ask to indirectly load an assembly and perform any operations you want on it. Working indirectly means the target assembly isn't loaded locally and will be cleanly unloaded with the separate Application Domain.

Easy, no?

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03