gpt4 book ai didi

c# - 将 HybridDictionary 序列化为 byte[]

转载 作者:行者123 更新时间:2023-12-04 07:00:29 32 4
gpt4 key购买 nike

我写了下面的代码

HybridDictionary state = new HybridDictionary();

using (MemoryStream buffer = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(buffer , state);


_backup.Push(buffer .ToArray());

}

但我在 formatter.serialize(st,state) 上遇到错误,如下所示:


System.Runtime.Serialization.SerializationException 未被用户代码处理
Message="类型 'System.ComponentModel.ReflectPropertyDescriptor' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 未标记为可序列化。"

这是什么意思 ?

最佳答案

添加

[field:NonSerializedAttribute()]
public event MyEventHandler SomeEvent;

到您的事件。这将从序列化中省略它们。

关于c# - 将 HybridDictionary 序列化为 byte[],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1939449/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com