序列化 ComponentModel.Container?

发布于 2024-08-19 00:53:02 字数 51 浏览 3 评论 0原文

是否可以序列化(二进制)System.ComponentModel.Container?

Is it possible to serialize (binary) a System.ComponentModel.Container?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

素食主义者 2024-08-26 00:53:02

不,它没有标记为可序列化。

No, it is not marked serializable.

风为裳 2024-08-26 00:53:02

您实际上想在这里做什么?如前所述,除非类型可序列化,否则不能使用 BinaryFormatter,但您还需要考虑容器中可能包含的所有内容。它们需要可序列化。

您可以通过不使用 BinaryFormatter 来解决“必须是 [Serializing]”问题,但大多数其他序列化程序(例如 XmlSerializer)都会有不预先知道所有子类以及诸如不可设置属性之类的问题。

如果您有正确的 .NET 版本,您还可以考虑 XamlWriter ,这可能会提供一些有趣的可能性。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文