Updating webparts in the GAC without using IISReset

  When deploying new versions of Webparts to the GAC, the general recommendation is to subsequentially run IISReset, since Sharepoint will not reload GAC-dlls as it would, had they been deployed to /bin.

However, for a production system this is a bit drastic (as it will cause all users to experience the dreaded “Service Unavailable” while IIS restarts), so I have been looking for alternatives.

It turns out that in order to reload a GAC-dll, all that is needed is to force an application pool recycle for the application pool Sharepoint is running within (default is MSSharePointPortalAppPool).
This can be accomplished using the MMC, or by running the following script (useful for webpart installers).

 Option Explicit
 '*** spsapppoolrecycle.vbs
 '*** Script to recycle Sharepoint Portal Server application pool
 '*** For use when deploying updated version of Webparts in the GAC
 '*** Author: Michael Christensen, mac@landscentret.dk
 '*** Provided AS IS with no warranties
 '*** Heavily based on this posting by David Wang:
 '*** http://tinyurl.com/4k26n
 Const WEBSITEID = 1
 Dim objApp
 Dim AppPoolId
 Dim objAppPool
 Set objApp = GetObject("IIS://localhost/w3svc/" & WEBSITEID  & "/root")
 AppPoolId = objApp.AppPoolId
 WScript.Echo "AppPoolID: " & AppPoolId
 Set objAppPool = GetObject( "IIS://localhost/w3svc/AppPools/" + AppPoolId )
 objAppPool.Recycle()
 WScript.Echo "AppPool recycled."

The script assumes that Sharepoint is installed on the virtuel server with ID 1. This will usually be the case, otherwise the actual ID could probably be determined programmatically.

Source: http://dotnetforum.dk/blogs/mac/archive/2005/07/18/65920.aspx


Follow

Get every new post delivered to your Inbox.