Tuesday, December 30, 2008

Loading & Unloading Assemblies from GAC on runtime


Recently we developed a tool for Inspecting whether the system has the required components for Silverlight SharePoint Integration.
This tool provides a checklist of things which are required & not installed on the users system and then allow the user to install them and re-run the Inspection.

The tricky part was to re-run the inspection for the assemblies in GAC. We were using the Assembly.Load method to dynamically load the assemblies from GAC and than just have a null check against it.
But the issue was that once we load the assemblies it doesn't allow to unload it. Which means that this would not work as expected when we try to re-run the inspection and try to re-load the same assembly within the same application domain.

The solution was to create a separate application domain and than load the assembly in that appdomain and than unload the appdomain once used.

Here is a sample code of the Inspection button click :

image

No comments:

AddIn