在运行时将对象标记为可序列化

编程入门 行业动态 更新时间:2024-10-27 20:24:21
本文介绍了在运行时将对象标记为可序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,

我正在使用序列化问题的第三方组件,因为开发人员可能忘记在控件前加上[Serializable()]或像这样......

I'm using a third part component that has a problem with serialization because the developers probably forgotten to prefix the control with the [Serializable()] or something like this..

因此,当需要序列化时,控件会导致异常。

So, the control causes an exception when needs to be serializable.

是否可以将该控件标记为可序列化?或者,更深入,是否可以修补程序集(或.exe)来纠正问题?我怎么能这样做?

Would it be possible to mark that control as serializable? Or, going deeper, would it be possible to patch the assembly (or .exe) to correct the issue? How could I do that?

提前致谢。

推荐答案

我认为这是可能的。

I dot think it is possible.

你可以做的是使用system.reflection做一些研究。您可以将对象复制到您的某个对象中并序列化您的对象,并在您更改时更新其对象。

What you could do is use system.reflection do some research on it. You could copy object into one of your object and serialize yours and when yours change update their object.

string key = object.GetType().FullName; PropertyInfo[] properties = System.Runtime.Remoting.Messaging.CallContext.GetData(key) as PropertyInfo[]; if (properties == null) { ArrayList items = new ArrayList(); PropertyInfo[] pageProperties = this.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance); foreach (PropertyInfo property in pageProperties) { if (property.CanRead) { string name = property.Name; object v = property.GetValue(this, null); ...

更多推荐

在运行时将对象标记为可序列化

本文发布于:2023-11-09 20:11:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时将   标记   对象   序列化

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!