Just followed the steps described by Ted Pattison at Creating and Using Event Handlers in Windows SharePoint Services 3.0 in my MOSS virtual machine to set up event handlers for the ItemAdded and ItemUpdated of a Sharepoint Custom List.
The problem is that I can’t put the event handlers to work. I’ve just removed all the code inside the event handlers and replaced it by some logging just to see if something happens. But nothing happens.
Here is the code:
class RequestIdentificationHandler : SPItemEventReceiver
{
public override void ItemUpdated(SPItemEventProperties properties)
{
Log(properties);
}
public override void ItemAdded(SPItemEventProperties properties)
{
Log(properties);
}
private void Log(SPItemEventProperties properties)
{
// Some logging code lines
}
}
I’ve placed the assembly in the GAC and registered the events:
SPSite site = new SPSite("http://server");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["CustomList"];
string asmName = "Assembly Name";
string clsName = "Class Name";
list.EventReceivers.Add(SPEventReceiverType.ItemUpdated, asmName, clsName);
list.EventReceivers.Add(SPEventReceiverType.ItemAdded, asmName, clsName);
I even used Patrick Tisseghem's Free Tool: Register Event Handlers Programmatically (WSS 2007) to register the events but the events don’t work.
But if I replace the events for the synchronous event versions, ItemAdding and ItemUpdating, everything works fine. The problem is that I can’t use these events, I have to use the ItemAdded and ItemUpdated.
I’ve looked into the Services console but everything seems working, and there aren’t no relevant services stopped.
Finally, I remembered that I had a clean Windows Server 2003 virtual machine, so I installed WSS V3 instead of MOSS. After WSS was installed, with the default configurations, I placed the assembly in the GAC, and registered the events and… the events worked!!!
The same code in my WSS V3 virtual machine works and in the MOSS virtual machine doesn’t work. I’ll continue to search for the solution but for now I just have to find a way to replace the events.
Hope to post here soon the solution for the problem…