Hi Tiraman,
I think in .NET we can unload an assembly, if we wants to do so, we have to
unload the appdomain which loads the assembly. Usually when an ASP.NET
application is running, it is running under an appdomain in the
aspnet_wp.exe and the necessary assebmlies will be loaded into the
appdomain , but if an Assembly is in GAC, it will be loaded into an
special appdomain(shared appdomain) which is indepent of the appdomain of
the asp.net application for performance and share concern.
So if an assembly is in the GAC, I think we can not force it to unload from
the memory, since we can not force the special appdomain to restart because
it will impact all the webapplication in the aspnet_wp.exe process. There
is an idleTimeout attribute of the processModel in the machine.config can
used to specifies the period of inactivity, in hr:min:sec string format,
after which ASP.NET automatically ends the worker process.(aspnet_wp.exe),
but this will impact the whole aspnet_wp.exe process, which cause the other
webapplication to be restarted. It will cause heavy performance hit so I do
not recommend you use the option.
I wonder why you need to control when the assembly will be unloaded from
the memory. Do you wants to implement the dynamically update? If so, I
think we'd better use the bindingRedirect in the web.config file. Since we
maintain the version of the assembly in GAC by changing its version if we
have made any updated.
Also in IIS6, we can run a webapplication at a indepent Application Pool,
so that if we recycle one webapplication by restart the worker process, it
will just restart this Application Pool. In this way, we will need arrange
all the webapplication will use the updated shared assembly in GAC to run
in the same application pool so that we do not need to create many
Application Pools.
The last method I think we will need to set back to deploy the shared
assembly in each bin folder of the web application, so everytime we change
the Web.config file, the Global.asax file, or any files in the Bin folder
will cause the appdomain which hosts the webapplication to restart. Also in
this way we have to make additional efforts to deploy the assembly into
multiple bin folders. But we can do by using a Batch file.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.