Issue in Copy and Paste Diagram Items

3 posts, 0 answers
  1. Ahmed
    Ahmed avatar
    16 posts
    Member since:
    May 2014

    Posted 26 Jan 2015 Link to this post

    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. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 26 Jan 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ahmed
    Ahmed avatar
    16 posts
    Member since:
    May 2014

    Posted 26 Jan 2015 in reply to Peshito Link to this post

    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 :)
Back to Top