단순히 DataGrid에 ObservableCollection을 바인딩하고, 한글을 빠르게 입력하면서 엔터를 계속 눌렀을 뿐임에도 아래와 같은 에러가 발생합니다.
OS : Windows 11 Pro, Home
.net 6.0, .net 8.0
Application: WpfApp1.exe
CoreCLR Version: 6.0.1623.17311
.NET Version: 6.0.16
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: 복구할 수 없는 시스템 오류입니다.
Stack:
at System.Environment.FailFast(System.String)
at System.Windows.Documents.TextStore.VerifyTextStoreConsistency()
at System.Windows.Documents.TextStore.GrantLock()
at System.Windows.Documents.TextStore.GrantLockWorker(LockFlags)
at System.Windows.Documents.TextStore.RequestLock(LockFlags, Int32 ByRef)
at MS.Win32.UnsafeNativeMethods+ITextStoreACPSink.OnSelectionChange()
at MS.Win32.UnsafeNativeMethods+ITextStoreACPSink.OnSelectionChange()
at System.Windows.Documents.TextStore.OnSelectionChanged()
at System.Windows.Documents.TextSelection.System.Windows.Documents.ITextRange.NotifyChanged(Boolean, Boolean)
at System.Windows.Documents.TextRangeBase.EndChange(System.Windows.Documents.ITextRange, Boolean, Boolean)
at System.Windows.Documents.TextRange.System.Windows.Documents.ITextRange.EndChange(Boolean, Boolean)
at System.Windows.Documents.TextRange+ChangeBlock.System.IDisposable.Dispose()
at System.Windows.Documents.TextEditorTyping.DoTextInput(System.Windows.Documents.TextEditor, System.String, Boolean, Boolean)
at System.Windows.Documents.TextEditorTyping+TextInputItem.Do()
at System.Windows.Documents.TextEditorTyping.ScheduleInput(System.Windows.Documents.TextEditor, InputItem)
at System.Windows.Documents.TextEditorTyping.OnTextInput(System.Object, System.Windows.Input.TextCompositionEventArgs)
at System.Windows.Controls.Primitives.TextBoxBase.OnTextInput(System.Windows.Input.TextCompositionEventArgs)
at System.Windows.UIElement.OnTextInputThunk(System.Object, System.Windows.Input.TextCompositionEventArgs)
at System.Windows.Input.TextCompositionEventArgs.InvokeEventHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
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.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.TextCompositionManager.UnsafeCompleteComposition(System.Windows.Input.TextComposition)
at System.Windows.Input.DefaultTextStore.OnTransitoryExtensionUpdated(ITfContext, Int32, ITfRange, ITfRange, Boolean ByRef)
at MS.Win32.UnsafeNativeMethods+ITfThreadMgr.SetFocus(ITfDocumentMgr)
at MS.Win32.UnsafeNativeMethods+ITfThreadMgr.SetFocus(ITfDocumentMgr)
at System.Windows.Documents.TextStore.OnGotFocus()
at System.Windows.Documents.TextServicesHost._RegisterTextStore(System.Windows.Documents.TextStore)
at System.Windows.Documents.TextStore.OnAttach()
at System.Windows.Documents.TextEditor.InitTextStore(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, 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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(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 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.Threading.DispatcherOperation.Wait(System.TimeSpan)
at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherOperation, System.Threading.CancellationToken, System.TimeSpan)
at System.Windows.Threading.Dispatcher.Invoke(System.Action, System.Windows.Threading.DispatcherPriority, System.Threading.CancellationToken, System.TimeSpan)
at System.Windows.Threading.Dispatcher.Invoke(System.Action, System.Windows.Threading.DispatcherPriority)
at System.Windows.Controls.DataGridTextColumn.OnInput(System.Windows.Input.InputEventArgs)
at System.Windows.Controls.DataGridCell.OnPreviewKeyDown(System.Windows.Input.KeyEventArgs)
at System.Windows.UIElement.OnPreviewKeyDownThunk(System.Object, System.Windows.Input.KeyEventArgs)
at System.Windows.Input.KeyEventArgs.InvokeEventHandler(System.Delegate, System.Object)
at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
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.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawKeyboardActions, Int32, Boolean, Boolean, Int32)
at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(System.Windows.Interop.MSG ByRef, Boolean ByRef)
at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(System.Windows.Interop.MSG ByRef, System.Windows.Input.ModifierKeys)
at System.Windows.Interop.HwndSource.OnPreprocessMessage(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(System.Windows.Interop.MSG ByRef, Boolean ByRef)
at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(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.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run()
at WpfApp1.App.Main()
문제를 재현해볼 수 있는 소스코드입니다. 매우 단순합니다.
MainWindow.xaml
<Window x:Class="WpfApp1.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:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<DataGrid ItemsSource="{Binding Items}">
</DataGrid>
</Grid>
</Window>
MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp1 {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window,INotifyCollectionChanged {
public ObservableCollection<TestItem> Items { get; set; } = new() {
new TestItem() {
Content = "sdf",
Title = "sdf"
}
};
public event NotifyCollectionChangedEventHandler? CollectionChanged;
public MainWindow() {
InitializeComponent();
DataContext = this;
}
}
}
TestItem.cs
namespace WpfApp1;
public class TestItem {
public string Title { get; set; }
public string Content { get; set; }
}
여러 다른 PC에서 실행시켜서 재현해봐도 항상 같은 오류가 발생합니다.
.net을 8.0으로 변경하여도 동일한 오류가 발생합니다.
현재로서는 Datagrid에서 한글을 빠르게 입력하면서 엔터를 눌렀을때 프로그램이 강제종료되는 문제를 해결할 수 없을까요?