2013-03-17 29 views
0

當調試我的應用程序時,我得到以下異常。如何分析這樣的異常?

我知道它與INotify屬性的更新方法有關,但如何找出究竟發生了什麼問題。我無法得到一個體面的堆棧調用。

完整例外信息是:當XAML初始化(在MainWindow.xaml文件在第4行)觸發錯誤初始化代碼

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: 
+1

你有'PcgTools.Model.Common.Synth.Timbre.get_UsedProgram()'代碼,或者它是第三方庫嗎? – 2013-03-17 22:07:50

回答

1

這種消息的apeears。真正的原因在內部例外中描述。這表明在Timbre.cs:line 137列表中訪問了一個無效的索引。

因爲它顯示該文件的行號,我假設你有它的源代碼,至少在.pdb文件的形式。比你可以在那裏設置一個斷點,看看發生了什麼。

跟蹤這種不清晰的異常的絕佳工具是IntelliTrace,但它僅適用於VS Ultimate。

+0

我感覺有點愚蠢......看起來,當一個人將完整的例外複製到剪貼板時,它顯示的信息多於屏幕上的信息。當我把它複製到這裏時,我沒有看到最後一部分在我自己的應用程序中完全顯示了導致它出現的部分。 但你完全應該得到解決方案。 是的,我有該代碼,並知道如何調試。雖然我沒有聽說過IntelliTrace。 – 2013-03-17 22:35:18