Why are System.Windows.Forms.Control not marked as serializable?

前端 未结 3 2008
星月不相逢
星月不相逢 2020-12-21 16:18

I am not able to deep copy UserControls because they are not marked as serializable.

What is the reason behind this design?

3条回答
  •  不知归路
    2020-12-21 17:05

    You can serialize Controls but not via standard serializers. If you'd like serialize one or more control on a form to save the form design and/or other control properties you can use the same serialization used by visual studio (via CodeDomSerializer) but you need to implement several classes (I think at least IDesignerSerializationManager). You can see a sample here

    http://support.microsoft.com/default.aspx?scid=kb;en-us;813808

    The serialization is in Class SampleDesignerLoader method Flush.

    In the same method there is also a serialization in an XML stream that does not use classes used by visual studio.

    In the same class there is the deserialization from XML.

提交回复
热议问题