开发者

Serialize ComponentModel.Container?

Is it possible to serialize (bi开发者_Go百科nary) a System.ComponentModel.Container?


No, it is not marked serializable.


What is it you actually want to do here? As has been noted, you can't use BinaryFormatter unless the type is serializable, but you would also need to consider all the things that might be contained in the container. They would also need to be serializable.

You can get around the "must be [Serializable]" issue by not using BinaryFormatter, but most other serializers (for example XmlSerializer) would have a problem with not knowing all the subclasses up-front, and things like non-settable properties.

If you have the right .NET versions, you could also consider things like XamlWriter, which may provide some interesting possibilities.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜