我如何分析这样的异常呢?
本文关键字:异常 | 更新日期: 2023-09-27 18:04:29
当调试我的应用程序时,我得到以下异常:
我知道它与INotify
属性的更新方法有关,但是如何找出究竟是什么出了问题。我不能得到一个像样的堆栈调用。
完整的异常信息为:
System.Windows.Markup.XamlParseException was unhandled
HResult=-2146233087
Message='The invocation of the constructor on type 'PcgTools.MainWindow' that matches the specified binding constraints threw an exception.' Line number '4' and line position '9'.
Source=PresentationFramework
LineNumber=4
LinePosition=9
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__1(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at PcgTools.App.Main() in c:'PcgTools'nodes'KorgKronosTools'obj'Debug'App.g.cs:line 0
InnerException: System.ArgumentOutOfRangeException
HResult=-2146233086
Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source=mscorlib
ParamName=index
StackTrace:
at System.Collections.Generic.List`1.get_Item(Int32 index)
at PcgTools.Model.Common.Synth.Timbre.get_UsedProgram() in c:'PcgTools'nodes'KorgKronosTools'Model'Common'Synth'Timbre.cs:line 137
at PcgTools.Model.Common.Synth.Timbre.RefillColumns() in c:'PcgTools'nodes'KorgKronosTools'Model'Common'Synth'Timbre.cs:line 612
at PcgTools.Model.Common.Synth.Timbre.OnPcgRootPropertyChanged(Object sender, PropertyChangedEventArgs e) in c:'PcgTools'nodes'KorgKronosTools'Model'Common'Synth'Timbre.cs:line 574
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at Common.Mvvm.ObservableObject.OnPropertyChanged(String propertyName, Boolean verifyPropertyName) in c:'PcgTools'nodes'Common'Mvvm'ObservableObject.cs:line 47
at PcgTools.Model.Common.Synth.Memory.set_ReadingFinished(Boolean value) in c:'PcgTools'nodes'KorgKronosTools'Model'Common'Synth'Memory.cs:line 74
at PcgTools.Model.Common.File.KorgFileReader.Read(String fileName) in c:'PcgTools'nodes'KorgKronosTools'Model'Common'File'KorgFileReader.cs:line 116
at PcgTools.ViewModels.MainViewModel.ReadAndShowFile(String fileName, Boolean checkAutoLoadMasterFileSetting) in c:'PcgTools'nodes'KorgKronosTools'ViewModels'MainViewModel.cs:line 367
at PcgTools.ViewModels.MainViewModel.HandleAppArguments() in c:'PcgTools'nodes'KorgKronosTools'ViewModels'MainViewModel.cs:line 1030
at PcgTools.MainWindow..ctor() in c:'PcgTools'nodes'KorgKronosTools'MainWindow.xaml.cs:line 221
InnerException:
当XAML初始化触发错误的初始化代码时出现这种消息(在MainWindow.xaml
文件的第4行)。真正的原因在内部异常中描述。说明在Timbre.cs:line 137
中访问了一个索引无效的列表。
因为它显示了该文件的行号,所以我假设您有它的源代码,至少以.pdb
文件的形式。然后你可以在里面设置一个断点,看看发生了什么。
IntelliTrace是跟踪这种不明确异常的一个很好的工具,但它只适用于VS Ultimate。