This is one of those ambiguous SharePoint 2007 COM+ exceptions that kept us troubleshooting at 2am. Many different causes and symptoms produce an HRESULT error. The one I’m covering here is HRESULT 0x80020009 (DISP_E_EXCEPTION). The particular symptom that we see in this case is when we try to add a custom web part on a page that read data from pages in the Pages Library. We check in a draft of the page then add an out of the box webpart like the content editor. Either when we add the content editor, or after we try to check in any changes, we get the very nasty HRESULT Exception.


In order to get some more detail on the cause of this ambiguous SharePoint HRESULT exception, we need to turn on verbose logging, reproduce the error, then dive into the SharePoint error logs. In our case, we got the following GetFileFromUrl: ArgumentException:
10/15/2009 00:34:19.42 w3wp.exe (0x10630) 0x84C4 CMS Publishing 6wyd Medium GetFileFromUrl: ArgumentException when attempting get file Url http://stage.yoursite.com/_catalogs/masterpage/YourPageLayout.aspx Value does not fall within the expected range. at Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder) at Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder) at Microsoft.SharePoint.SPWeb.GetMetadataForUrl(String relUrl, Int32 mondoProcHint, Guid& listId, Int32& itemId, Int32& typeOfObject, Object& fileOrFolder) at Microsoft.SharePoint.SPWeb.GetFileOrFolderObject(String strUrl) at Mic...
Notice the page layout URL points to staging. The site in question is in production. So the issue here is a custom webpart is reading data from a page that references a page layout from a different environment.
This happens sometimes when you manually move pages across environments using SharePoint Designer, i.e. from staging to production.
Solution
The good news is it’s easy to spot and fix this incorrect page layout referencing error.
- In SharePoint Designer, click Task Panes -> Hyperlinks
- In the Hyperlink pane, click the bottom "Show Internal Hyperlinks" icon (bottom icon on left side)
- Click the "Verify Hyperlinks" icon and verify all hyperlinks (top icon on left side)
- Sort the results by the Hyperlink column and scroll to links starting with http://
- Look for any links referencing page layouts in an environment other than your current environment, i.e. staging when the page is in prod
- Right click and go to Edit Hyperlink. Change the reference to the production URL and click Replace
- Verify the changes by re-running "Verify Hyperlinks"
I really hope this helps for some of you. There are many causes to an HRESULT error in SharePoint and this is one possible solution. Be sure to leave comments below.
Big thanks to Josh Gaffey from our project team for figuring out the solution.
Hey! I was able to fix the layout referencing error, I got stuck at that part. Thanks for the info...
ReplyDeletePage. L