New answers tagged object-model
Are you sure that /Lists/TestList is the right (relative) URL? Try the SPUrlUtility.CombineUrl method: https://msdn.microsoft.com/EN-US/library/office/microsoft.sharepoint.utilities.spurlutility.combineurl.aspx Something like this: List targetList = targetWeb.GetList(SPUrlUtility.CombineUrl(targetWeb.ServerRelativeUrl, "/_catalogs/yourList"));
SPList list = web.GetList("/Lists/TestList"); Should be SPList list = web.GetList(web.ServerRelativeUrl + "/Lists/TestList"); As it needs the server relative URL to your list
You should use server relative Url of the list: Example: The server-relative URL to the root folder of a list, such as /sites/sitecollection/subsite/Lists/Announcements.
Top 50 recent answers are included