0

I have a custom SharePoint timer job for SharePoint 2010. High level structure of code in Execute method is given below and there is try catch at each level:

public override void Execute(Guid targetInstanceId)
{
  using (SPSite site = new SPSite("URL"))
  {
    using (SPWeb rootWeb = site.OpenWeb())
    {
      SPList someList = web.Lists.TryGetList("ListName");
      // query, add, update some list items
    }
  }
}

List operations are failing randomly every few minutes with errors involving SPRequest:

OWSTIMER.EXE: NullReferenceException in SPRequest: Object reference not set to an instance of an object. at Microsoft.SharePoint.Library.SPRequest.SetVar(String bstrUrl, String bstrName, String bstrValue)

Before above exceptions for OWSTIMER.EXE, we are seeing below exceptions for w3wp.exe:

w3wp.exe: An SPRequest object was not disposed before the end of this thread. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it. This object will now be disposed.

Since w3wp.exe and OWSTIMER.EXE are separate processes, I presume disposing of objects in one should not affect the other. However, as per the logs, these appear to be correlated. Any ideas on how to debug this issue. Specifically, how can I find out if this is due to some buggy code running as part of w3wp.exe or is it a problem with my code of the timer job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.