我有一个 WPF 应用程序,我在不同的线程中运行一些动画,所以我的主 UI 线程将响应。我正在使用此处发布的代码:
Thread thread = new Thread(() =>
{
Window1 w = new Window1();
w.Show();
w.Closed += (sender2, e2) => w.Dispatcher.InvokeShutdown();
System.Windows.Threading.Dispatcher.Run();
});
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
它通常工作正常,但在系统部署后,我收到了有关应用程序崩溃的投诉,并显示以下堆栈跟踪:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.List`1.RemoveAt(Int32 index)
at System.IO.Packaging.PackagePart.CleanUpRequestedStreamsList()
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream()
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Window1.xaml:line 1
at Window1..ctor()
有没有人见过这个异常并且可以解释那里发生了什么?这个特定例外的原因可能是什么?
我正在使用 .Net 3.5 SP1