当使用 MSTest 进行单元测试时,我创建了一个 WPF 窗口。当此窗口关闭时,Visual Studio 显示InvalidComObjectException
:
COM object that has been separated from its underlying RCW cannot be used.
它在退出后[TestMethod]
引发,并且堆栈仅包含外部代码(否InnerException
)。这就是我所拥有的:
StackTrace:
at System.Windows.Input.TextServicesContext.StopTransitoryExtension()
at System.Windows.Input.TextServicesContext.Uninitialize(Boolean appDomainShutdown)
at System.Windows.Input.TextServicesContext.TextServicesContextShutDownListener.OnShutDown(Object target, Object sender, EventArgs e)
at MS.Internal.ShutDownListener.HandleShutDown(Object sender, EventArgs e)
DeclaringType:
{Name = "TextServicesContext" FullName = "System.Windows.Input.TextServicesContext"}
Assembly:
{PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35}
这是创建窗口的代码:
var myWindow = new SomeWindow(errors);
myWindow.ShowDialog();
该窗口包含两个ListView
s,其中包含一些文本元素和复选框