Jump to content
Software FX Community

Exception after changing to final version, "Specified index is out of range or child at index is null...


srickenb
 Share

Recommended Posts

We've finally changed from the last Beta version to the final version of WPF Chart.

Having not touched our application code we get now a very nasty exception. It occurs when visual parts holding charts (e.g.TabItems) are being switched and it seems to be a problem with sizing functions in the framework. As our code is not involved wen the exception is thrown it is impossible to track the problem down. 

charts are initially shown correctly.

Thank you for your help 

Stefan

The error message is as follows:

"Specified index is out of range or child at index is null. Do not call this method if VisualChildrenCount returns zero, indicating that the Visual has no children.\r\nParameter name: index\r\nActual value was 0." 

 And the stack trace is as follows:

at System.Windows.FrameworkElement.GetVisualChild(Int32 index)

at System.Windows.Media.Visual.InternalGet2DOr3DVisualChild(Int32 index)

at System.Windows.Media.VisualTreeHelper.GetChild(DependencyObject reference, Int32 childIndex)

at ChartFX.WPF.Animation.SeriesAnimation.ChartFX.WPF.IAnimation.Attach(FrameworkElement owner, Object oldItem, Object newItem, AnimationFlags flags)

at ChartFX.WPF.Internal.PlotAreaCore.b(LogicalItemCollection A_0, LogicalItemCollection A_1, PaintMark A_2)

at ChartFX.WPF.Internal.PlotAreaCore.a(LogicalItemCollection A_0, LogicalItemCollection A_1, PaintMark A_2)

at ChartFX.WPF.Internal.PlotAreaCore.a(Double A_0, Double A_1, Boolean A_2)

at ChartFX.WPF.Internal.PlotAreaCore.b(Double A_0, Double A_1, Boolean A_2)

at ChartFX.WPF.Internal.PlotAreaCore.a(RenderStyles A_0, Double A_1, Double A_2)

at ChartFX.WPF.Chart.a(RenderStyles A_0)

at ChartFX.WPF.Chart.i(Boolean A_0)

at ChartFX.WPF.Chart.MeasureOverride(Size constraint)

at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

at System.Windows.UIElement.Measure(Size availableSize)

at System.Windows.ContextLayoutManager.UpdateLayout()

at System.Windows.UIElement.UpdateLayout()

at System.Windows.Controls.TabItem.OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)

at System.Windows.UIElement.OnPreviewGotKeyboardFocusThunk(Object sender, KeyboardFocusChangedEventArgs e)

at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

at System.Windows.Input.InputManager.ProcessStagingArea()

at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)

at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew)

at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)

at System.Windows.UIElement.Focus()

at System.Windows.Controls.TabItem.SetFocus()

at System.Windows.Controls.TabItem.OnMouseLeftButtonDown(MouseButtonEventArgs e)

at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)

at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)

at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)

at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)

at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

at System.Windows.Input.InputManager.ProcessStagingArea()

at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)

at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)

at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

at System.Windows.Interop.HwndSource.InputFilterMessage(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, Boolean isSingleParameter)

at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)

at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)

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.Threading.Dispatcher.PushFrame(DispatcherFrame frame)

at System.Windows.Threading.Dispatcher.Run()

at System.Windows.Application.RunDispatcher(Object ignore)

at System.Windows.Application.RunInternal(Window window)

at System.Windows.Application.Run(Window window)

at System.Windows.Application.Run()

at SCSFContrib.CompositeUI.WPF.ApplicationShellApplication`2.Start()

at Microsoft.Practices.CompositeUI.CabApplication`1.Run()

at WPFCABShell.Shell.Entry.Main() in C:\Users\srickenb\Documents\Visual Studio 2008\Projects\PMwpf2\PMwpf\Shell\Shell\Entry.cs:line 51

at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

Link to comment
Share on other sites

Can you please check the version of the ChartFX.WPF.dll? If it is version 8.0.3422 it is possible we have already fixed this issue and it is available as a hotfix.

You can either download our most recent hotfix here or post/send us a small app that duplicates the issue if you want us to investigate this problem before upgrading your bits.

JuanC

Link to comment
Share on other sites

We've just applied the hotfix. However, the library still crashes in several places when tabs are switched in the manner I've described above.

As we are a software provider company for the financial industry and your library is used in a major project with a tight deadline, this puts as in a very difficult situation. If it is possible to get the stable version against we have programmed (8.0.3309.21029) without the "expired" note we could survive until the current problem is solved.

Of course we would support you in helping to fix the problem.

Please help us!

Thanks

Stefan 

 

Link to comment
Share on other sites

If you have a local copy of the 3309 build you should be able to use it instead of the most recent builds. The expiration is in the license and not the dll so if you already installed the trial you should be good to go (until the trial expires 30 days after installation).

If you do not have a backup copy of this build please send an email to sales at softwarefx dot com, normally we do not keep all binaries for all versions released while in beta but we can always recompile it.

JuanC

Link to comment
Share on other sites

Thank you, that should help us to cope with the situation!

There remains one thing to make sure: Once we've bought the final license, can we distribute our applicaton with the older version without getting an "expired" at the customer? In other words, are we free to distribute any version (even the Beta) to our customers and not running into the expired problem?

Can you explain briefly where and what the license file is and what we need to make sure in order to achieve a smooth transition to deployment and dstribution with the freedom of choosing older versions?

We investigated a little further and found out that the instable situation arises from reassigning the ItemsSource of a chart, regardless whether this is done by binding or direct assignment (in C# in our case). If an immediate Refresh() is done after assigning, the situation seems to improve considerably.

As we want to go forward with the latest version as soon as possible, how can we find out when the problem is solved?

Regards

Stefan

Link to comment
Share on other sites

Normally we prefer that our customers ship the released bits, I would recommend you send an email to sales at softwarefx dot com so that we can discuss your situation offline.

About finding out when the problem is solved: Please try posting a repro case or include more details of this issue as we have been unable to reproduce the bug.

Regards,

JuanC

Link to comment
Share on other sites

Please find attached a repro case.

Do the following

- Click "Add Point"

- Select Tab2

- Click "Add Point"

- Select Tab1

- Click "Add Point"

 In additon, the application shows also a few more unexpected effects:

- Charts are not updated, when in an unselected tab and show stale data when they reaplear in the selected tab

- Legends of pie charts disapear when data changes (Therefore, the collapsed/visible statements)

Regards and thanks

Stefan

Link to comment
Share on other sites

>> Legends of pie charts disapear when data changes

This issue has been fixed on build 3558

>> Charts are not updated, when in an unselected tab and show stale data when they reaplear in the selected tab

This as well as the exception is trickier, the events we receive when you navigate away from a tab are similar to the ones generated when a window/page with a chart is closed. To avoid memory leaks we tear down our visuals and also disconnect from notification changes in your data. To workaround this issue you will want to change your code as follows

  public Window1()

  {

  InitializeComponent();

  MainGrid.DataContext = this;

  chart1.AdvancedSettings |= ChartFX.WPF.ChartSettings.KeepVisualsOnUnload;

  chart2.AdvancedSettings |= ChartFX.WPF.ChartSettings.KeepVisualsOnUnload;

  this.Unloaded += new RoutedEventHandler(OnUnloaded);

  }

  private void OnUnloaded (object sender, RoutedEventArgs e)

  {

  chart1.AdvancedSettings &= ~ChartFX.WPF.ChartSettings.KeepVisualsOnUnload;

  chart2.AdvancedSettings &= ~ChartFX.WPF.ChartSettings.KeepVisualsOnUnload;

  }

Note that is very important that when the window is being uploaded your turn off the flags to make sure we can cleanup properly. Failing to do this might create memory leaks.

JuanC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...