event handler: Cannot complete this action

I made an event handler for doclibs to log the document updating and deletion activities. After deployment, the event handler for document library was logging the delete event but giving the exception on update event: “Cannot Complete this action, Please try again.”
After much effort, I found that the problem was with WSS Service Pack 2, and the exception was raised when try to access SPListItem collection.
The issue was because of increased security with WSS sp2.
http://support.microsoft.com/default.aspx?scid=kb;en-us;909455

The resolution is
using System.Security.Principal …
WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate();
//implement OM code here
wic.Undo();

Advertisements

Attach an Event sink with Multiple Document Libraries

Attach an Event sink with Multiple Document Libraries
There is no easy way in SPS 2003 to attach an event sink with multiple document libraries. You have to iterate each one manually or programmatically, following is the hack for this (SPS 2003)
For existing doclibs
Db: _Site
update lists set
     tp_EventSinkAssembly = ‘WSSEventSink, Version=1.0.0.0, Culture=neutral,                                          PublicKeyToken=56761703e95c64a0’,
     tp_EventSinkClass =’WSSEventSink.EventSink’
where tp_ServerTemplate = 101 –doclib

For newly created doclibs
Schema.XML
<List  EventSinkAssembly=”WSSEventSink, Version=1.0.0.0, Culture=neutral, PublicKeyToken=56761703e95c64a0″ EventSinkClass=”WSSEventSink.EventSink”