I have an Event Handler that overrides the ItemAdded method. This works fine on my DEV environment but on my LIVE environment it doesn’t fire. I’m wondering if there is something wrong with the way I have set it up.
The class is declared like this.
public class SitesEventHandler : SPItemEventReceiver {
public override void ItemAdded(SPItemEventProperties properties) {
//... code removed.
}
}
I’ve added the event handler like this:
SPList sites = web.Lists["Sites"];
sites.EventReceivers.Add(SPEventReceiverType.ItemAdded, "MossServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e99", "MossServices.SitesEventHandler");
I know that the event has been added but I’m wondering if there is a step I’ve missed out.
EDIT
I have found that it runs fine when I use it as an administrator but not as anyone else. I must admit I suspected it could be permissions. Would anyone be able to tell me why it works for a systems administrator but not a content manager? Again, is there anything in the set up I should have done?
Thanks
The problem here wasn’t with the way the event handler/receiver was registered or with the code within the class. It was a problem with permissions.
What really helped me was looking in the logs that Sharepoint writes:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS
This link helped me with my particular problem:
http://sharenotes.wordpress.com/2008/03/18/cannot-open-log-for-source-you-may-not-have-write-access/
Hope this helps someone. This does have the feel of a dirty hack, but sometimes the option to entirely scrap a system and re-do the years of previous dirty hacks just isn’t an option.