Exception Info: System.InvalidCastException: Unable to cast object of type 'System.__ComObject' to type 'ITfThreadMgr'.
在使用wpf 多次打开关闭同一窗体后,部分电脑会出现输入法报错,导致软件崩溃,请问这是什么原因造成的,使用了捕获异常的软件还是崩溃了,怎么操作能使软件不崩溃呢?
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
Application.Current.DispatcherUnhandledException += App_DispatcherUnhandledException;(实现了 e.Handled = true;)
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
通过附加进程获取到的报错信息如下:
捕获的错误信息如下:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidCastException: Unable to cast object of type 'System.__ComObject' to type 'ITfThreadMgr'.
at System.StubHelpers.InterfaceMarshaler.ConvertToManaged(IntPtr& ppUnk, IntPtr itfMT, IntPtr classMT, Int32 flags)
at MS.Win32.UnsafeNativeMethods.TF_CreateThreadMgr(ITfThreadMgr& threadManager)
at MS.Internal.TextServicesLoader.Load()
at System.Windows.Threading.Dispatcher.GetMessagePump()
at System.Windows.Threading.Dispatcher.GetMessage(MSG& msg, IntPtr hwnd, Int32 minMessage, Int32 maxMessage)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at iTour.App.Main()