I recently upgraded from Sharepoint 2007 to 2010. I have a windows service that inserts pdfs into sharepoint. It works great on 2007. When I migrated to 2010, I started getting the following intermittent error:
<nativehr>0x80070002</nativehr> 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.GetList(String strUrl)
Here is the offending line of code:
SPList parentList = web.GetList(url);
What's weird, is that this only occasionally fails. I've actually wrapped this line of a loop, and if it it fails, I wait a bit, and then try to get the list again. Usually after a few tries, the GetList will succeed.
Since it's not easly duplicatable, I'm looking for any leads I might be able to track down.
From google searches, the "recommend" fix is to change any .GetList(...) calls to SPWeb.Lists[".."];
But, I got away from that, due to the perf hit on 2007 ( .GetList(...) has better perf than SPWeb.Lists["..."])
SPWeb.GetList Method will certainly raise error if list is not there in the site. The method is designed like that. It is already documented in msdn.
If you are unsure that list is there or not; use
Webobject.List[ListName] to avoid exception.
You can check my blog SharePoint Codes for sample code
I think this is late reply, but hope it helps others in future.
User contributions licensed under CC BY-SA 3.0