为什么System.Windows.Clipboard
(PresentationCore.dll)对
System.Windows.Thickness
(PresentationFramework.dll)不友好但对System.Windows.Point
(WindowsBase.dll)友好
using System;
namespace ConsoleApplication5 {
class Program {
/*
* Add references to
* WindowsBase.dll (Point)
* PresentationFramework.dll (Thickness)
* PresentationCore.dll (Clipboard)
*/
[STAThread]
static void Main(string[] args)
{
Test myTest = new Test();
System.Windows.Clipboard.SetData("myformat", myTest);
// OutOfMemoryException
Object myPastedTest = System.Windows.Clipboard.GetData("myformat");
}
}
[Serializable]
class Test
{
// COMMENT THE LINES BELLOW PresentationFramework TO WORK OK!
// PresentationFramework.dll
//public System.Windows.Thickness MyThickness { get; set; }
public System.Windows.Media.Brush MyBrush { get; set; }
// WindowsBase.dll
public System.Windows.Point MyPoint { get; set; }
}
}