化的错误,当复制、粘贴从windows形式的控制以WPF控制

0

的问题

我们有一个序列化类保留的数据的剪贴板从一个窗口控制WPF控制。 这个工作在框架4.8后转换。净5现在,我们得到的错误: 类型的系统。RuntimeType'在大会'的系统。私人的。CoreLib,Version=5.0.0.0、文化=中立的,程序=7cec85d7bea7798e'不被标记为序列化。

这发生在拉事件处理程序WPF在线:

var tClip = e.Data.GetDataPresent(typeof(ClipboardDescriptor));

在"e"的系统。窗户。为drageventargs.

using System;
using System.Windows.Forms;

namespace Support.Classes
{
    /// <summary>
    /// Summary description for ClipboardDescriptor.
    /// </summary>
    [Serializable]
    public class ClipboardDescriptor
    {
        private Guid id;
        private Guid parentDocumentID;
        private System.Type objtype;
        private TreeNode baseTreeNode;
        private string objname;

        public ClipboardDescriptor()
        {
            baseTreeNode = null;
        }

        public Guid ParentDocumentID
        {
            get { return(parentDocumentID); }
            set { parentDocumentID = value; }
        }

        public Guid ID
        {
            get { return(id); }
            set { id = value; }
        }

        public System.Type ObjType
        {
            get { return(objtype); }
            set { objtype = value; }
        }

        public string ObjName
        {
            get { return(objname); }
            set { objname = value; }
        }

        /// <summary>
        /// Get the treenode that this object is associated with
        /// </summary>
        public TreeNode BaseTreeNode
        {
            get { return(baseTreeNode); }
            set { baseTreeNode = value; }
        }
    }
}
.net-5 c# wpf
2021-11-22 21:52:28
1

最好的答案

0

这是修复。 在这种情况下幸运的是树节点酒店是不必要的和TypeName财产可能会加入这样的类型可以检索它。

using System;

namespace JMPT.Support.Classes
{
    /// <summary>
    /// Summary description for ClipboardDescriptor.
    /// </summary>
    [Serializable]
    public class ClipboardDescriptor
    {
        public Guid ParentDocumentID { get; set; }
        public Guid ID { get; set; }
        [field: NonSerialized]
        public Type ObjType { get; set; }
        public string ObjName { get; set; }
        public string ObjTypeName { get; set; }
    }
}
  
2021-11-23 16:59:35

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................