前提・実現したいこと
C#のWPFで、テキストボックスを使用した簡単なToDoリストを作成しようとしています。
まずはxamlにTextBoxのみを配置し、デバッグ実行でキーボードから文字を入力したところ、以下の例外エラーが発生しました。
なお、exeから起動した時は、テキスト入力によりアプリが落ちるような現象は見られませんでした。
教えていただきたいのは
・例外の発生原因は何か
・解決法はあるか
・この例外は無視して良いものかどうか
・無視して良いものである場合、デバッグ時に動作を中断させない方法はあるか
です。
発生している問題・エラーメッセージ
System.ComponentModel.Win32Exception HResult=0x80004005 Message=パラメーターが間違っています。 Source=WindowsBase スタック トレース: 場所 MS.Win32.UnsafeNativeMethods.GetWindowText(HandleRef hWnd, StringBuilder lpString, Int32 nMaxCount) 場所 System.Windows.Automation.Peers.WindowAutomationPeer.GetNameCore() 場所 System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree() 場所 System.Windows.ContextLayoutManager.fireAutomationEvents() 場所 System.Windows.ContextLayoutManager.UpdateLayout() 場所 System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) 場所 System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() 場所 System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 場所 System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) 場所 System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) 場所 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 場所 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) 場所 System.Windows.Threading.DispatcherOperation.InvokeImpl() 場所 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) 場所 MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj) 場所 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) (f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs):行 954 場所 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) (f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs):行 901 場所 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) (f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs):行 890 場所 MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) 場所 System.Windows.Threading.DispatcherOperation.Invoke() 場所 System.Windows.Threading.Dispatcher.ProcessQueue() 場所 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 場所 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 場所 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 場所 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 場所 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) 場所 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) 場所 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 場所 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 場所 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 場所 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 場所 System.Windows.Application.RunDispatcher(Object ignore) 場所 System.Windows.Application.RunInternal(Window window) 場所 System.Windows.Application.Run(Window window) 場所 System.Windows.Application.Run() 場所 WpfApp1.App.Main()
該当のソースコード
<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="350" Width="525"> <StackPanel> <TextBox></TextBox> </StackPanel> </Window>
C
1using System; 2using System.Collections.Generic; 3using System.Linq; 4using System.Text; 5using System.Threading.Tasks; 6using System.Windows; 7using System.Windows.Controls; 8using System.Windows.Data; 9using System.Windows.Documents; 10using System.Windows.Input; 11using System.Windows.Media; 12using System.Windows.Media.Imaging; 13using System.Windows.Navigation; 14using System.Windows.Shapes; 15 16namespace WpfApp1 17{ 18 /// <summary> 19 /// MainWindow.xaml の相互作用ロジック 20 /// </summary> 21 public partial class MainWindow : Window 22 { 23 public MainWindow() 24 { 25 InitializeComponent(); 26 } 27 } 28} 29
補足
半角英数字・全角英数字・ひらがな・カタカナ・記号・漢字などを入力してみたところ、
全角英数字・ひらがな("1","あ","k"など)を入力すると例外が発生するようでした
また、必ず発生するわけではなく、
TextBoxにフォーカスを合わせ、最初の一文字目で発生することもあれば、
数文字入力して発生することもあります。
実行環境は以下になります。
・windows10 64bit
・visualstudio2017 version 15.5.7
・.net Framework4.7

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。