in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Roni's SharePoint Thoughts

A developer blog about SharePoint technologies (MOSS and WSS)

Canceling Check-out Event in Lists and Document Libraries returns an Error Message

With the new event model in WSS 3.0 we have the ability to cancel some user actions on the behalf of synchronous events like ItemUpdating or ItemDeleting.

To do this you have to implement an event handler: Create a class library with a class that inherit from Microsoft.SharePoint.SPItemEventReceiver. And then override the desired event methods (ItemDeleting, ItemUdating, …).

Now you have to register your event handler within SharePoint. You can do this programmatically through the object model or declaratively through a feature for a specific list type or a specific content type. Details are well documented in the WSS SDK. There is also a nice book excerpt about the whole story of event handling in WSS: http://www.wrox.com/WileyCDA/Section/id-306329.html

To cancel an event you can use the following code in your event handler:

public override void ItemCheckingOut(SPItemEventProperties properties)
{
    properties.Status = SPEventReceiverStatus.CancelWithError;
    properties.ErrorMessage = "Operation not allowed because...";
    properties.Cancel = true;
}

With ItemDeleting or ItemUpdating this is working perfectly: the user action will be canceled and the user will be presented the custom error message "Operation not allowed …".

But with ItemCheckingOut is something wrong. The user action (Check-out) is canceled but the user will be presented the following system error message instead of our custom error message:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

I also tested this with WSS/MOSS SP1 (Technical Preview) and got exactly the same behavior.

Did anyone come across this issue (bug?) or does anyone know a workaround?

Comments

 

Links (9/6/2007) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (9/6/2007) « Steve Pietrek’s SharePoint Stuff

September 6, 2007 7:30 PM
 

Mattias Andersson said:

Yes, I have the same issue. I try to cancel the checkout, but my message is not displayed. If anyone knows about a solution to this I would be happy to here it too.

September 7, 2007 2:56 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts