调试我的应用程序时,我得到以下异常。
我知道它与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:
答案 0 :(得分:1)
当XAML初始化触发错误的初始化代码时(MainWindow.xaml
文件中的第4行),这种消息会出现。真正的原因在内部异常中描述。它表示在Timbre.cs:line 137
中使用无效索引访问列表。
因为它显示了该文件的行号,我假设你有源代码,至少是.pdb
文件的形式。你可以在那里设置一个断点来看看发生了什么。
用于跟踪此类不明确异常的优秀工具是IntelliTrace,但它仅适用于VS Ultimate。