It's sharepooint bug connecting with GetItems by SPView object. When you will retrieve view from list, for example: list.Views["View Name"] ViewFields contains only two fields(Title, LinkTitle) and the SPQuery for retrieved view is empty. If you wanna to filter your list items or get fields via SPQuery class.
Also you wanna to get working state the GetItems(spView) method. You can reset HttpContext and then try to get spView.
For example:
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
}