This is a migrated thread and some comments may be shown as answers.

Issue in Copy and Paste Diagram Items

2 Answers 45 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 26 Jan 2015, 06:22 AM
Hi,

Sometimes when copy and paste diagram items, I get error says "An item with the same key has already been added."

Here is the call stack
==========================================================================================

System.ArgumentException was unhandled
  HResult=-2147024809
  Message=An item with the same key has already been added.
  Source=mscorlib
  StackTrace:
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at Telerik.Windows.Diagrams.Core.SerializationService.DeserializeItems(SerializationInfo serializationInfo, Boolean makeUnique)
       at Telerik.Windows.Controls.Diagrams.DataTransferService.HandleDiagramElementDrop(DataObject dataObject)
       at Telerik.Windows.Controls.Diagrams.DataTransferService.HandlePaste(DataObject dataObject, Action`1 action)
       at Telerik.Windows.Controls.RadDiagram.Paste()
       at Telerik.Windows.Controls.RadDiagram.OnPasteCommandExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
       at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
       at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
       at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
       at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
       at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
       at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
       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 System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
       at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run()

========================================================

Thanks,

Ahmed

2 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 26 Jan 2015, 11:34 AM
Hi Ahmed,

I tried to reproduce  your issue but to no avail. The sample I worked on is attached to this thread. Could you please modify the sample so the issue becomes reproducible or simply attach a runnable copy of yours. As this is a forum thread, you should either submit a support ticket or use a third party web site for files sharing.

Regards,
Peshito
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ahmed
Top achievements
Rank 1
answered on 26 Jan 2015, 02:03 PM
Hi Peshito,

Found the issue, it was with deserializing the custom shape. The problem is solved when I use (make unique) flag while deserializing

SerializationService.Default.DeserializeItems(itemsSerializationInfo, true)

Thank you :)
Tags
Diagram
Asked by
Ahmed
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Ahmed
Top achievements
Rank 1
Share this question
or