[ActiProSoftware.Shell.Wpf] Program 'Freezes' if a file gets deleted in folder from Windows Explorer

Shell for WPF Forum

Posted 5 years ago by XArtur0
Version: 19.1.0684
Platform: .NET 4.8
Environment: Windows 10 (64-bit)
Avatar

Edit - More info:

This also happens on the ShellListViewIntro Demo if LayoutMode is set to MediumIcons (possibly others). 

--------------------

I'm using a ShellListView to display a folder, but if I navigate to that same folder with windows explorer, create a file and then delete the file, the program would either freeze or crash (if I click any icon) with the stacktrace below.


Steps to reproduce:
Start program
Navigate to ‘My Documents’
Create ‘New Text Document.txt
Delete said file
(ShellListView does not get updated)
Click Anything inside ShellListView
(Application Crashes)

Stacktrace

System.ArgumentException
HResult=0x80070057
Message=GeneratorPosition '-1,1' passed to Remove does not have Offset equal to 0.
Parameter name: position
Source=PresentationFramework
StackTrace:
at System.Windows.Controls.ItemContainerGenerator.Remove(GeneratorPosition position, Int32 count, Boolean isRecycling)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.Remove(GeneratorPosition position, Int32 count)
at #w6j.#Tpk.#mpk(Int32 #npk, Int32 #LX)
at #w6j.#Tpk.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at WpfApp2.App.Main()

This exception was originally thrown at this call stack:
System.Windows.Controls.ItemContainerGenerator.Remove(System.Windows.Controls.Primitives.GeneratorPosition, int, bool)
System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.Remove(System.Windows.Controls.Primitives.GeneratorPosition, int)
#w6j.#Tpk.#mpk(int, int)
#w6j.#Tpk.MeasureOverride(System.Windows.Size)
System.Windows.FrameworkElement.MeasureCore(System.Windows.Size)
System.Windows.UIElement.Measure(System.Windows.Size)
System.Windows.ContextLayoutManager.UpdateLayout()
System.Windows.ContextLayoutManager.UpdateLayoutCallback(object)
System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
...
[Call Stack Truncated]

MainWindow.xaml.cs

using System;
using System.ComponentModel;
using System.Windows;

namespace WpfApp2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            Shell.RootShellFolderParsingName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            Shell.DisposeShellInstances();

            base.OnClosing(e);
        }
    }
}

MainWindow.xaml

<Window x:Class="WpfApp2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp2"
        xmlns:shell="http://schemas.actiprosoftware.com/winfx/xaml/shell"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <shell:ShellListView x:Name="Shell" LayoutMode="MediumIcons" RootSpecialFolderKind="Default">
            <!--<shell:ShellListView.DefaultShellService>
                <local:ShellService />
            </shell:ShellListView.DefaultShellService>-->
        </shell:ShellListView>
    </Grid>
</Window>

[Modified 5 years ago]

Comments (1)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thank you for reporting this.  I believe we tracked down where it happens and are able to add some code to prevent it.  If you'd like to try a preview build with the update, please write our support address and reference this thread.


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.