C# 使用资源管理器序列化数据的替代方法

C# 使用资源管理器序列化数据的替代方法,c#,winforms,windows-forms-designer,embedded-resource,.net-core-3.0,C#,Winforms,Windows Forms Designer,Embedded Resource,.net Core 3.0,我有一个从组件继承的自定义控件,自定义控件的属性之一是MemoryStream type。我使用资源文件中生成的MemoryStream在LayoutStream属性中存储了一些布局状态信息。但在NetCore 3.0中,不支持MemoryStream序列化存储在资源文件中的数据。有关此问题,请参阅此链接(“) NetCore 3.0中出现异常 Exception thrown: 'System.Runtime.Serialization.SerializationException' in S

我有一个从组件继承的自定义控件,自定义控件的属性之一是MemoryStream type。我使用资源文件中生成的MemoryStream在LayoutStream属性中存储了一些布局状态信息。但在NetCore 3.0中,不支持MemoryStream序列化存储在资源文件中的数据。有关此问题,请参阅此链接(“)

NetCore 3.0中出现异常

Exception thrown: 'System.Runtime.Serialization.SerializationException' in System.Runtime.Serialization.Formatters.dll
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in System.Runtime.Serialization.Formatters.dll
Type 'System.IO.MemoryStream' in Assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is not marked as serializable.
请建议任何替代解决方案来序列化存储在资源文件中的数据

this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));

customcontrol  = new MyControl(this.components);
this.panel2 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.customcontrol )).BeginInit();
this.SuspendLayout();
// 
// customcontrol  
// 


this.customcontrol.LayoutStream = ((System.IO.MemoryStream)(resources.GetObject("customcontrol  .LayoutStream")));

@PanagiotisKanavos我已经查看了您共享的源代码。在该源代码中,它被标记为可序列化。但是在最新的更新中,MS删除了MemoryStream类中的可序列化属性。因此我们无法使用MemoryStream序列化和反序列化数据。您可以在VS2019 16.3版本中重现该问题。我只需要一个So用于序列化和反序列化数据(存储在resx文件中)而不是使用MemoryStream的解决方案。是否对此进行了更新?是否对此进行了更新?