This project is read-only.

Error in System.Windows.Controls.DataVisualization.Charting.PieSeries

Apr 24, 2009 at 2:11 PM
I'm now getting this exception when the Scrum Sprint Monitor starts loading the screens:

System.Collections.Generic.KeyNotFoundException was unhandled
  Message="The given key was not present in the dictionary."

I think it may be related to this: http://blogs.msdn.com/delay/archive/2009/03/25/supporting-the-unsupported-two-fixes-for-the-unofficial-wpf-charting-assembly.aspx

I don't know for sure. I'll post the stack trace in the next message.
Apr 24, 2009 at 2:12 PM
Here is the stack trace:

System.Collections.Generic.KeyNotFoundException was unhandled
  Message="The given key was not present in the dictionary."
  Source="mscorlib"
  StackTrace:
       at System.ThrowHelper.ThrowKeyNotFoundException()
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at System.Windows.Controls.DataVisualization.Charting.PieSeries.UpdateLegendItemIndexes()
       at System.Windows.Controls.DataVisualization.Charting.PieSeries.RemoveDataPoint(DataPoint dataPoint)
       at System.Windows.Controls.DataVisualization.Charting.DataPointSeries.RemoveObject(Object dataContext)
       at System.Windows.Controls.DataVisualization.Charting.DataPointSeries.LoadDataPoints(IEnumerable newItems, IEnumerable oldItems)
       at System.Windows.Controls.DataVisualization.Charting.DataPointSeries.Refresh()
       at System.Windows.Controls.DataVisualization.Charting.DataPointSeries.OnSizeChanged(Object sender, SizeChangedEventArgs e)
       at System.Windows.SizeChangedEventArgs.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 e)
       at System.Windows.FrameworkElement.OnRenderSizeChanged(SizeChangedInfo sizeInfo)
       at System.Windows.ContextLayoutManager.fireSizeChangedEvents()
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       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.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       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, 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 ScrumSprintMonitor.Wpf.Application.App.Main() in C:\Downloads\Open\Scrum Sprint Monitor\scrumsprintmonitor-22697\main\src\app\ScrumSprintMonitor.Wpf.Application\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
Apr 24, 2009 at 6:05 PM
That is very strange. That problem supposedly was fixed some time ago, and I haven't come across it since. It must be some situation on your particular data (or data transition) that is causing it. Does this happen every time you start the application, or after it has been running for some time?
Apr 24, 2009 at 6:19 PM
It happens everytime now. Is there any particular data I could collect to help debug the issue?
Apr 24, 2009 at 6:41 PM
Not that I can think of. Are you at the begining of a sprint? Did anything change since one week ago (team members, sprint, etc.)?
Apr 24, 2009 at 6:52 PM
We are in the middle of a sprint. Not all of our teams were tracking their items in TFS and have just recently added a lot of items as they started moving over. We've added a couple more members for those teams.

I don't want have to start debugging the charting stuff. Hmmm...if only I had a clue that would point me in the right direction. Is there a simple way to just disable the charting in the code that you know of? Like commenting out a couple lines of code? It may not be worth the trouble.
Apr 25, 2009 at 12:07 AM
Edited Apr 25, 2009 at 12:08 AM
To disable the charting stuff I would just go through the XAML files and comment out the <charting:Chart> blocks. That should free you of the exception.
Apr 27, 2009 at 11:00 PM
I finally had a little time to play around with this. Just for grins I changed charting:PieSeries to charting:BarSeries (line 31 in SprintOverviewChart.xaml) and the error went away. I guess our project numbers are triggering an obscure bug in the PieSeries. I'll leave it like that for now.

If nothing else, the bars look kind of neat. ;-)
Apr 28, 2009 at 11:28 AM
I have reported this issue to the Silverlight Toolkit team. Hopefully they will find the problem and post a fix for it. The issue here is that I am using the charting components from Silverlight Toolkit. They weren't tested for the WPF platform (yet). In the future though, this will eventually get supported by Microsoft, and we will have more stable versions to run on.
Apr 28, 2009 at 10:58 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 28, 2009 at 11:02 PM
David Anson from the Silverlight Toolkit kindly offered a workaround that he would like us to test. I have uploaded a patch rar file in http://scrumsprintmonitor.codeplex.com/SourceControl/PatchList.aspx. Please let me know if it worked for you and I will integrate it into the next release.

Regards,
Pedro
Apr 29, 2009 at 2:20 PM

The workaround got me past the error!

I pulled code from changeset 22987 and could reproduce the original error. I then copied in the patch you linked and the error went away.

I don't know if this is related or not, but I wanted to give you as much information as I can. I noticed some different behavior in the pie charts. The sprint overview pie charts and only some of the member pie charts are now half circles. They seem to be accurate in the size of each slice for each work item type, but instead of a full circle, they are a half circle. I also noticed that the colors for these half-circles don't match up with the colors in the legend below the pie chart. They appear to be using a different color scheme (more blue and purple).

Also, a couple of the member pie charts are smaller. I can determine what the pattern is, but out of 27 members 10 of them have a tiny pie chart for the "Work" pie chart. The "Backlog Items" pie chart on all of them is the normal size.

We just changed up some of the numbers and the sprint overview pie charts are now full circles and the correct color scheme. (The tiny pie charts are still there.) It seems like the numbers are changing the behavior.

Once again, I'm not sure if all of this is related, I just want to give you as much information as possible.

Thank you for your hard work!

Apr 29, 2009 at 11:58 PM
Thanks bebo,

By any chance, do you think it would be possible for you to send me a screenshot of your monitor? That might help determine the cause of this issue.
Apr 30, 2009 at 1:36 PM
Yes, I can do that. What's the best way to get the screenshot to you?
Apr 30, 2009 at 2:32 PM
I think I have figured out the reason for the small pie charts...wait for it...when there is a 3 digit number, the pie sizes smaller to make room. ;-) No big mystery there. I still haven't determined a pattern that could cause the half pies.