Copy and paste between two instances of the application

Hi,
I redesign my application to do undo/redo from beginning based on the infos of the “serialization”-Thread here in the forum.
I have a Node with the properties x,y,z,width and height and type (for using different templates) only.
But now I realized that even is this early state I can’t do copy on one instance of the application and paste it to another instance.
Inside one instance copy and paste is working as expected!

Any hint?

If I run two instances of GoWpfBasic.exe, I am able to select a node or two in one window and paste the other window.

Are you sure you have made the model serializable, which is required for the Windows clipboard? For example, note how the data classes in the GoWpfBasic model are [Serializable].

I inherited my Model from:

public class DiagramModel : GraphLinksModel<Element, String, String, ElementLink>
{
    public DiagramModel()
    {
        Modifiable = true;
        HasUndoManager = true;
    }
}

And my Node looks the following:

public class Element : GraphLinksModelNodeData<String>, IDisplay
{
    private ElementType type;

    private int width;
    private int height;
    private int x;
    private int y;
    private int z;

    public Element()
    {
        Debug.WriteLine("Element constructor");
        Key = Guid.NewGuid().ToString();
        BackgroundColor = Colors.Blue;
        BorderColor = Colors.Red;
        ForegroundColor = Colors.White;
        NoDisplayAndShowPlaceholder = false;
    }

    public int X
    {
        get { return x; }
        set
        {
            if (x != value)
            {
                var old = x;
                x = value;
                RaisePropertyChanged("X", old, value);
            }
        }
    }

    public int Y
    {
        get { return y; }
        set
        {
            if (!y.Equals(value))
            {
                var old = y;
                y = value;
                RaisePropertyChanged("Y", old, value);
            }
        }
    }

    public int Z
    {
        get { return z; }
        set
        {
            if (!z.Equals(value))
            {
                var old = z;
                z = value;
                RaisePropertyChanged("Z", old, value);
            }
        }
    }

    public int Width
    {
        get { return width; }
        set
        {
            if (!width.Equals(value))
            {
                var old = width;
                width = value;
                RaisePropertyChanged("Width", old, value);
            }
        }
    }

    public int Height
    {
        get { return height; }
        set
        {
            if (!height.Equals(value))
            {
                var old = height;
                height = value;
                RaisePropertyChanged("Height", old, value);
            }
        }
    }

    public ElementType Type
    {
        get { return type; }
        set
        {
            if (!type.Equals(value))
            {
                var old = type;
                type = value;
                RaisePropertyChanged("Type", old, value);
            }
        }
    }


    private Color backgroundColor;

    public Color BackgroundColor
    {
        get { return backgroundColor; }
        set
        {
            if (!backgroundColor.Equals(value))
            {
                var old = backgroundColor;
                backgroundColor = value;
                RaisePropertyChanged("BackgroundColor", old, value);
            }
        }
    }

    private Color backgroundColorSelected;

    public Color BackgroundColorSelected
    {
        get { return backgroundColorSelected; }
        set
        {
            if (!backgroundColorSelected.Equals(value))
            {
                var old = backgroundColorSelected;
                backgroundColorSelected = value;
                RaisePropertyChanged("BackgroundColorSelected", old, value);
            }
        }
    }

    private Color borderColor;

    public Color BorderColor
    {
        get { return borderColor; }
        set
        {
            if (!borderColor.Equals(value))
            {
                var old = borderColor;
                borderColor = value;
                RaisePropertyChanged("BorderColor", old, value);
            }
        }
    }

    private Color borderColorSelected;

    public Color BorderColorSelected
    {
        get { return borderColorSelected; }
        set
        {
            if (!borderColorSelected.Equals(value))
            {
                var old = borderColorSelected;
                borderColorSelected = value;
                RaisePropertyChanged("BorderColorSelected", old, value);
            }
        }
    }

    private Color foregroundColor;

    public Color ForegroundColor
    {
        get { return foregroundColor; }
        set
        {
            if (!foregroundColor.Equals(value))
            {
                var old = foregroundColor;
                foregroundColor = value;
                RaisePropertyChanged("ForegroundColor", old, value);
            }
        }
    }

    private Color foregroundColorSelected;

    public Color ForegroundColorSelected
    {
        get { return foregroundColorSelected; }
        set
        {
            if (!foregroundColorSelected.Equals(value))
            {
                var old = foregroundColorSelected;
                foregroundColorSelected = value;
                RaisePropertyChanged("ForegroundColorSelected", old, value);
            }
        }
    }

    private bool noDisplayAndShowPlaceholder;

    public bool NoDisplayAndShowPlaceholder
    {
        get { return noDisplayAndShowPlaceholder; }
        set
        {
            if (!noDisplayAndShowPlaceholder.Equals(value))
            {
                var old = noDisplayAndShowPlaceholder;
                noDisplayAndShowPlaceholder = value;
                RaisePropertyChanged("NoDisplayAndShowPlaceholder", old, value);
            }
        }
    }
}

In the Output-Window I see the following when I paste:

‘MyApplication.vshost.exe’ (Managed (v4.0.30319)): Loaded ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\DevExpress.Xpf.Grid.v14.2.Core.resources\v4.0_14.2.0.0_de_b88d1754d700e49a\DevExpress.Xpf.Grid.v14.2.Core.resources.dll’
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC& format, STGMEDIUM& medium)
at System.Windows.DataObject.OleConverter.GetDataInner(FORMATETC& formatetc, STGMEDIUM& medium)
at System.Windows.DataObject.OleConverter.GetDataFromOleHGLOBAL(String format, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetDataFromBoundOleDataObject(String format, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert)
at System.Windows.DataObject.GetData(String format, Boolean autoConvert)
at System.Windows.Clipboard.GetDataInternal(String format)
at System.Windows.Clipboard.GetData(String format)
at Northwoods.GoXam.CommandHandler.PasteFromClipboard()
at Northwoods.GoXam.CommandHandler.Paste()

Hi Walter,
do you still have my demo program? That one form the Serialization-Thread.

There the copy and paste also doesn’t work.

I send you the code to the support email.

Yes, that error looks like a serialization failure. Did you try [Serializable] ?