Sharepoint Event Handler stops trigger/firing
- Hi,
I have an item adding event handler attached to a list. This event handler was working working for a month, and today it just stopped working.
The event handler just accesses the root folder's properties collections list and retrieves a value, updates it and stores it back.
Here is a snippet of the code:
SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite siteColl= new SPSite("http://someurl/")) { using (SPWeb currentSite = siteColl.OpenWeb()) { //get the start counter int startCounter = 0; //allow any user to update currentSite.AllowUnsafeUpdates = true; //get current list SPList currentList = currentSite.Lists["Projects"]; //if it doesnt contain the job number key add it with the custom job number if (!currentList.RootFolder.Properties.ContainsKey("JobNumberCounter")) { currentList.RootFolder.Properties.Add("JobNumberCounter", "2224"); } //parse the counter to a number startCounter = int.Parse(currentList.RootFolder.Properties["JobNumberCounter"].ToString()); //if regular job -- generate auto increment job number if (jobType.Equals("Job")) { ++startCounter; properties.AfterProperties[jobNumberInternalName] = startCounter; currentList.RootFolder.Properties["JobNumberCounter"] = startCounter.ToString(); currentList.RootFolder.Update(); }
Does anyone know why this is happening? Is retrieving and updating the root folder's properties collection not reliable? This worked for a month and suddenly today it stopped.
Answers
- Looking in google i found that:
Please make sure the identity for the SharePoint Application Pool has sufficient permissions to write to the Event Log.
* Make the identity a Local Administrator
or
* Grant permissions as follows:
- Start > Run > Regedit
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
- Right click on "Eventlog" > Permissions
- Add the SharePoint AppPool identity with Full Control to the list
Check:
http://www.moss2007.be/blogs/vandest/archive/2007/07/24/profilepictureeventhandler.aspx
http://paulgalvin.spaces.live.com/default.aspx?_c11_BlogPart_pagedir=Next&_c11_BlogPart_handle=cns!1CC1EDB3DAA9B8AA!791&_c11_BlogPart_BlogPart=blogview&_c=BlogPart&sa=517219724
Juan Pablo.
surpoint.blogspot.com
excelza.blogspot.com- Marked As Answer byff4930 Thursday, November 05, 2009 3:11 PM
- Hi,
I agree with Paul, please try giving the app pool account admin privledges on the server first.
There is a chance that permission setting on server has been changed.
Best Regards,
-Aaron- Marked As Answer byff4930 Thursday, November 05, 2009 3:11 PM
All Replies
- Hi,has everything stopped working? I mean, does it get triggered or not ?Greets,Frank
- The event handler does get triggered but the retrieving from properties collection is not occuring.
- are there any error msg in event viewer/sharepoint logs? if it stops running, there should be some logs indicating it. Unless there patches done or something..
Never stop learning. Hi,
Please follow converscient and Pablo’s advice, check your log file to get some error information at
Driver:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS
Best Regards,
-Aaron
- The error I get from Event Viewer was "Requested registry access is not allowed". The above code worked fine for a month and it just stopped working and gave me that error. Can someone please help?
- Looking in google i found that:
Please make sure the identity for the SharePoint Application Pool has sufficient permissions to write to the Event Log.
* Make the identity a Local Administrator
or
* Grant permissions as follows:
- Start > Run > Regedit
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
- Right click on "Eventlog" > Permissions
- Add the SharePoint AppPool identity with Full Control to the list
Check:
http://www.moss2007.be/blogs/vandest/archive/2007/07/24/profilepictureeventhandler.aspx
http://paulgalvin.spaces.live.com/default.aspx?_c11_BlogPart_pagedir=Next&_c11_BlogPart_handle=cns!1CC1EDB3DAA9B8AA!791&_c11_BlogPart_BlogPart=blogview&_c=BlogPart&sa=517219724
Juan Pablo.
surpoint.blogspot.com
excelza.blogspot.com- Marked As Answer byff4930 Thursday, November 05, 2009 3:11 PM
- Did you try programmtically pulling down a list of Event Receivers using something like SPList.EventReceivers and see if the correct events are registered to your list receiver?
SPSite siteColl= new SPSite("http://someurl/");
SPWeb currentSite = siteColl.OpenWeb();
SPList list = currentSite.Lists["some list"];
int numberOfEventHandlersInCurrentList = list.EventReceivers.Count;
try to run the above code in your utility (console app or win app) on ur server and see if the count has number greater than 0 or not. If it is then, use SPEventReceiverDefinitionCollection type to see which event handlers are register to the list.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.eventreceivers.aspx
- Hi,
I agree with Paul, please try giving the app pool account admin privledges on the server first.
There is a chance that permission setting on server has been changed.
Best Regards,
-Aaron- Marked As Answer byff4930 Thursday, November 05, 2009 3:11 PM
- The above solution just gives the rights to log the error in the event viewer correct?
Shouldn't the code I have with elevated priveleges work?
The Sharepoint server I am deploying my event handler does not have VS, is there any other way to debug this? Hi,
You can refer this article How to: Set Up Remote Debugging (http://msdn.microsoft.com/en-us/library/bt727f1t.aspx).
This article includes a detailed process of remote debugging.
The ASP.NET worker process (aspnet_wp.exe) usually runs with an account called ASPNET, so you must use this account (or an account with equal or greater privileges) to remotely debug it.
You can create a specific account for the remote debugger and make sure it has appropriate access.
Please tell us the feedback for further help.
Best Regards,
-Aaron- I solved the problem guys. Thanks for the help, apparently the problem was that the appPool was under some other account rather the Network Service's. Thanks all!!

