Why WPF ApplicationCrash uses Listview
I am facing the issue of crashing WPF application. I have a search screen, it will search in a single textbox, use vertualization, but sometimes it crashes when I am on the search screen. I have a validation event viewer and you will find below information.
I am using a very low config system for the same application.
Application: Lotus.TILL.UI.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: Unrecoverable system error.
Stack:
at System.Environment.FailFast(System.String)
at MS.Internal.Invariant.FailFast(System.String, System.String)
at System.Windows.Automation.Peers.GridViewItemAutomationPeer..ctor(System.Object, System.Windows.Automation.Peers.ListViewAutomationPeer)
at System.Windows.Automation.Peers.GridViewAutomationPeer.System.Windows.Automation.Peers.IViewAutomationPeer.CreateItemAutomationPeer(System.Object)
at System.Windows.Automation.Peers.ListViewAutomationPeer.CreateItemAutomationPeer(System.Object)
at System.Windows.Automation.Peers.ItemsControlAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.ListViewAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32)
at System.Windows.Automation.Peers.ItemsControlAutomationPeer.UpdateChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.ContextLayoutManager.fireAutomationEvents()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(System.Object)
at System.Windows.Media.MediaContext+InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(System.Object)
at System.Windows.Media.MediaContext.RenderMessageHandler(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
at System.Windows.Window.ShowHelper(System.Object)
at System.Windows.Window.Show()
at System.Windows.Window.ShowDialog()
at Lotus.TILL.Infrastructure.UI.Controls.DialogWindow.OpenDialogWindow(System.Windows.Window, Lotus.TILL.Infrastructure.UI.BaseViewModel, Lotus.TILL.Common.Entities.ReferenceData.DialogAnimationType, System.Object)
at Lotus.TILL.UI.ShellViewModel.LoadCustomDialog(Double, Double)
at Lotus.TILL.UI.ShellViewModel.DiscoverDialog(Lotus.TILL.Common.Entities.ToolbarItem, Boolean)
at Lotus.TILL.UI.ShellViewModel.ShowDialogCommandExecute(System.Object)
at Lotus.TILL.Infrastructure.UI.Helpers.DelegateCommand.Execute(System.Object)
at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
at System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs, System.Windows.RoutedEvent)
at System.Windows.UIElement.OnMouseUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawMouseActions, Int32, Int32, Int32)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr, Boolean ByRef)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run(System.Windows.Window)
at Lotus.TILL.UI.App.Main()
The code I am using to find an item.
public class ShopItemsProvider : IItemsProvider<SaleItem>
{
const int _fetchDelay = 200; //ms
readonly string _searchTxt;
readonly bool _searchAnyWhere;
IList<SaleItem> _items;
readonly SearchType _searchType = SearchType.None;
/// <summary>
/// Initializes a new instance of the <see cref="DemoCustomerProvider"/> class.
/// </summary>
/// <param name="count">The count.</param>
/// <param name="fetchDelay">The fetch delay.</param>
public ShopItemsProvider(SearchType type, string searchTxt, IList<SaleItem> plofItems, bool searchAnyWhere = false)
{
_searchType = type;
_searchTxt = searchTxt;
_searchAnyWhere = searchAnyWhere;
_items = plofItems;
}
public int FetchCount()
{
return Data.Count();
}
public ReadOnlyCollection<SaleItem> PlofItems
{
get { return new ReadOnlyCollection<SaleItem>(_items); }
}
public IQueryable<SaleItem> Data
{
get
{
Thread.Sleep(_fetchDelay);
IEnumerable<SaleItem> data;
var filteredShopItems = DataRepository.ShopItems.Where(x => x.ItemType == SaleItemType.Grocery || x.ItemType == SaleItemType.News);
switch (_searchType)
{
case SearchType.ShopItems:
data = filteredShopItems;
break;
case SearchType.PlofItems:
data = PlofItems;
break;
default:
return new List<SaleItem>().AsQueryable();
}
if (string.IsNullOrEmpty(_searchTxt) || _searchTxt.Length < 1)
return data.AsQueryable<SaleItem>();
if (_searchAnyWhere)
return (from rows in data
where (rows.Name != null && rows.Name.Contains(_searchTxt, StringComparison.InvariantCultureIgnoreCase))
|| (rows.ScannedBarcode != null && rows.ScannedBarcode.Contains(_searchTxt, StringComparison.InvariantCultureIgnoreCase))
select rows).AsQueryable<SaleItem>();
return (from rows in data
where (rows.Name != null && rows.Name.Trim().StartsWith(_searchTxt, StringComparison.InvariantCultureIgnoreCase))
|| (rows.ScannedBarcode != null && rows.ScannedBarcode.StartsWith(_searchTxt, StringComparison.InvariantCultureIgnoreCase))
select rows).AsQueryable<SaleItem>();
}
}
/// <summary>
/// Fetches a range of items.
/// </summary>
/// <param name="startIndex">The start index.</param>
/// <param name="count">The number of items to fetch.</param>
/// <returns></returns>
public IList<SaleItem> FetchRange(int startIndex, int count)
{
List<SaleItem> result = null;
try
{
//return Data.OrderBy(c => c.BaseBarcode).Skip(startIndex).Take(count).ToList();
result = Data.OrderBy(c => c.Name).Skip(startIndex).Take(count).ToList();
}
catch (Exception ex)
{
UIExceptionHandler.LogException(ex, "Search Fetch Reange Exception");
}
return result;
}
}
Please help me with this.
Thanks, Rajnikant
+3
source to share
No one has answered this question yet
Check out similar questions: