R – SharePoint COMException

comexceptionpublishingsharepointworkflow

When adding or editing a page in a SharePoint Pages library we get the following exception:

[COMException (0x81020016): Item does not exist
The page you selected contains an item that does not exist. It may have
been deleted by another user. Click "Home" at the top of the page to return
to your Web site.]
at Microsoft.SharePoint.Library.SPrequestInternalClass.RenderColumn.

The weird thing is, when we first do "Check in" and then click the Publish button it works perfectly. But clicking "Publish" directly generates theis error, BUT NOT ALWAYS!

The Pages library has publishing and item planning on, NO workflow (seeing as the person who adds / edit pages is also the approver) and Major/ Minor versions.
We use a content type derived from publishing page and a custom PageLayout.

Best Answer

I'm sure you would have already checked this but is there any more information in the ULS logs?

Also have you tried setting the debugger to break on all exceptions and does this give you more information? Go to Debug, Exceptions and tick Common Language Runtime Exceptions. Then go to Tools, Options, Debugging and untick Enable Just My Code. Finally attach to w3wp.exe.

If you are running Windows Server 2008 you could also try taking a dump file at the point the debugger breaks above. ADPlus might help if you are running Server 2003 but I don't have experience with it. You should then be able to open the dump file with DumpChk or WinDbg.

Edit: As discussed in the comments, this is code deployed to production that can't have its service interrupted. The only way you could create a dump file is programmatically. Have a look at this question I asked that will hopefully help you if you need to go down this route.

Other things to try if you don't want to get down and dirty with debugging is to try deploying your custom bits to a clean server. See if you can still reproduce the problem or if it changes.