This is a sharepooint error related to the GetItems of a SPView object. When you get the view from the list, for example: list.Views ["View Name"] ViewFields contains only two fields (Title, LinkTitle), and SPQuery for the removed view is empty. If you want to filter list items or get fields through the SPQuery class.
You also want to get the working state of the GetItems (spView) method. You can reset the HttpContext and then try to get spView.
For instance:
private SPListItemCollection GetItemsByEventType() { HttpContextHelper.ResetCurrent(); SPList list; try { SPWeb web = Context.Site.OpenWeb(Context.Web.ID); try { list = web.Lists[ListName]; } catch (Exception) { list = web.GetListFromUrl(ListName); } if (!String.IsNullOrEmpty(ListViewName)) { SPView view = list.Views.Cast<SPView>() .Where(t => t.Title == ListViewName) .FirstOrDefault(); return list.GetItems(view); } } finally { HttpContextHelper.RestoreCurrent(); } return list.Items; } protected new SPContext Context { get { return SPContext.GetContext(base.Context); } } public class HttpContextHelper { #region Fields [ThreadStatic] private static HttpContext _current; #endregion #region Methods public static void ResetCurrent() { if (_current != null) { throw new InvalidOperationException(); } _current = HttpContext.Current; HttpContext.Current = null; } public static void RestoreCurrent() { HttpContext.Current = _current; _current = null; } #endregion }
source share