Category Archives: WSS 3.0

Replicating SPThemes.XML Changes to Multiple FrontEnds

After being asked to create a new custom SharePoint 2007 Theme on an environment with three front-end servers for an internal project, I soon noticed (post deployment) that the Add/Remove items changes in the SPThemes.xml file performed by the FeatureReciever were not replicated propertly to all of the web front-end servers.  After some investigation I found that within the FeatureReciever code I needed to execute the AddThemeItem/RemoveThemeItem function calls from inside the FeatureInstalled/FeatureUninstalling events rather than the FeatureActivated/FeatureDeactivating events.

This is because in a SharePoint farm with multiple servers, the FeatureActivated/FeatureDeactivating event only gets fired on a single server on the farm!

By putting the AddThemeItem/RemoveThemeItem function calls in the FeatureInstalled/FeatureUninstalling events instead, the code will get fired on every server in the farm.

Quick Example:

public class FeatureReceiver: SPFeatureReceiver {
public override void FeatureActivated(SPFeatureReceiverProperties properties) {
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) {
}
public override void FeatureInstalled(SPFeatureReceiverProperties properties) {
AddThemeItem();
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties) {
RemoveThemeItem();
}
}

Vimal Naran – Senior Developer

1 Comment

Filed under Fixes / Solutions, SharePoint 2007, WSS 3.0