An odd exception thrown in .NET.

An exception is thrown: "System.ComponentModel.ReflectPropertyDescriptor is not marked as Serializable"

Does this mean that I missed designating something as a serializable self, or is it something out of my control?

+4
source share
3 answers

It is under your control. Most likely the problem is the same: http://www.codeplex.com/SharedCache/Thread/View.aspx?ThreadId=19759

+1
source

Can you give more information about when this will happen and with what serializer? Most serializers have the ability to ignore certain elements - NonSerializedAttribute for BinaryFormatter , XmlIgnoreAttribute for XmlSerializer , etc.

Having an instance of PropertyDescriptor in your class usually means that your class acts like a bag of properties; in this case, you may need to do custom serialization ( ISerializable / IXmlSerializable ). If there is a field for any other reason, just check it to ignore it.

These (or similar symptoms) are also very common when you have an event (for example, a change notification event / INotifyPropertyChanged ) that a user interface is connected to (data binding); in this case, you need to mark the support field as unserialized. I do not know about VB, but with C # you can do this using "field events" as follows:

 [field: NonSerialized] public event EventHandler BarChanged; 
+4
source

You have a field of this type in your class. If this is the case, you will have to implement ISerializable yourself - automatic implementation requires all your fields to be marked as Serializable.

+1
source

Source: https://habr.com/ru/post/1277562/


All Articles