My site is setup to use SharePoint 2010's automated Application Pool Recycling. I have 2 front end web servers.

Sometimes (not everytime) the application pool recycles, and a custom webpart starts to display "Object reference not set to an instance of an object." This only happens on 1 of the front end servers, not both. Also, it is not always the same front end server. Furthermore it isn't always the same webpart.

I error handle the webparts, so the site/page still comes up. The webpart just doesn't appear. The SharePoint logs only mention "Object reference..."

If I recycle the application pool again everything returns to normal (the webpart starts working as normal).

Are there issues with SharePoint's automated app pool recycling? Anything I might want to try to relieve this issue?

  • 1
    Does any of the OOB webparts fail or is it only affecting your custom webparts? Apr 26, 2011 at 15:31
  • Just custom, but they don't always fail. Its not always the same ones that fail. With 2 front end servers one of them might have a failed webpart, but the other server works fine. If I recycle the app pool on the failing server it begins to work again. ...and it only seems to happen after the automated recycle.
    – mcnarya
    Apr 26, 2011 at 17:02

2 Answers 2


Since this is only custom web parts, I would suggest reviewing the code. This message (obviously) means that the code is expecting a value to exist that doesn't at the time it renders. Possible something in cache or the like.

If this same behavior happens on your Dev farm you can disable the custom error pages so that you can see the underlying error message as that will be more useful.

  • If the webpart errors out I would expect it to do so on both front end servers. That isn't happening. It only errors out on one of them. It's random, not always the same server and seems to only happen after the automated app pool recycle. Otherwise the code works fine. Caching is an interesting observation. We are caching. That I will look into.
    – mcnarya
    Apr 26, 2011 at 16:54
  • If you are using custom caching code that is expecting certain cached values to exist. Also, if you are using the PortalSiteMapProvider, there are isolated cases I've seen where that does not return the objects expected.
    – Dave Wise
    Apr 26, 2011 at 17:51

You might want to play with web gardening settings of both servers so they recycle at the same time. Make sure enough memory is allocated so it's not recycling automaticaly because it exceeds the allocated memory. Set both WFEs to recycle on a schedule to run at the same time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.