5
votes

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["..."])

Any suggestions?

Thanks!
Dave

3
Have you tried to web.Lists.TryGetList() ? msdn.microsoft.com/en-us/library/…Alexey

3 Answers

0
votes

Maybe you could understand the error better if you first retrieved an SPFolder or SPFile related to the url in question. Check .GetFile(...).Exists and .GetFolder(...).Exists. You could also get the ParentList property hence.

0
votes

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.

0
votes

What resolved exact same error on SPWeb.GetList(reletiveUrl) with error thrown in method GetMetadataForUrl on SharePoint 2010:

  • restart IIS
  • restart SPTimerV4 (SharePoint 2010 Timer)
  • restart SPAdminV4 (SharePoint 2010 Administration)