Exception Info: System.InvalidCastException: Unable to cast object of type 'System.__ComObject' to type 'ITfThreadMgr'.

丶 岳 0 信誉分
2024-07-29T08:03:52.5733333+00:00

在使用wpf 多次打开关闭同一窗体后,部分电脑会出现输入法报错,导致软件崩溃,请问这是什么原因造成的,使用了捕获异常的软件还是崩溃了,怎么操作能使软件不崩溃呢?

TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

Application.Current.DispatcherUnhandledException += App_DispatcherUnhandledException;(实现了 e.Handled = true;)

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

通过附加进程获取到的报错信息如下:

6a74032a821a750a59c665279dad713

7fd2a6f29be7f7253da9a55194d1344

e018abe500b58a4e9939d0e853e524f

捕获的错误信息如下:

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()

Windows Presentation Foundation
Windows Presentation Foundation
.NET Framework 的一部分,它提供统一的编程模型,用于在 Windows 上构建业务线桌面应用程序。
126 个问题
C#
C#
一种面向对象的类型安全的编程语言,它起源于 C 语言系列,包括对面向组件的编程的支持。
176 个问题
{count} 票

你的答案

问题作者可以将答案标记为“接受的答案”,这有助于用户了解已解决作者问题的答案。