SharePoint Error : System.ArgumentException. Value does not fall within the expected range

之前做SharePoint的时候遇到这个错误 .....
System.ArgumentException. 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 Microsoft.SharePoint.Publishing.CommonUtilities.GetFileFromUrl(String url, SPWeb web)
最后在blogs.technet.com找到了解决办法
原因就是:
The reason for this problem is that backup/restore does not adjust the references from the publishing page objects in the Pages library to their Page Layouts. These URLs are sometimes stored as absolute URLs including the server name. And this server name is the server name of the old server farm which cannot be resolved on the new farm.

解决办法 :
In case that you have run into the above problem you have two options:
  1. Throw away the database and transfer it correctly using STSADM -o export/import or content deployment
  2. Fix the incorrect links manually using the following steps
    1. Open the web in SharePoint Designer
    2. On the “task panes” window, pick hyperlinks.
    3. For the “hyperlink” heading, click the arrow and pick (custom…)
    4. In the dialog, ask to show rows where the hyperlink begins with a URLs which are not valid on the current server farm
    5. For each of the files, right click and say “Edit hyperlink…” and Replace hyperlink with the hyper link that is valid on the current server farm

他那里有个stsadm扩展可以解决问题, 不过在客户那里我只有写个Console给客户自己运行了
新建一个Console Application

Code

运行一次搞掂,Thanks to Stefan Goßner !

posted @ 2009-01-20 11:39  chris_thanks  阅读(3081)  评论(2编辑  收藏  举报