Note that there are some explanatory texts on larger screens.

plurals
  1. PODesign time serialization in C#
    text
    copied!<p>I have created a non-visual component in C# which is designed as a placeholder for meta-data on a form.<br> The component has a property which is a collection of custom objects, this object is marked as Serializable and implements the GetObjectData for serilizing and public constuctor for deserilizing.<br></p> <p>In the resx file for the form it will generate binary data for storing the collection, however any time I make a change to the serialized class I get designer errors and need to delete the data manually out of the resx file and then recreate this data.</p> <p>I have tried changing the constuctor to have a try / catch block around each property in the class</p> <pre><code>try { _Name = info.GetString("Name"); } catch (SerializationException) { this._Name = string.Empty; } </code></pre> <p>but it still crashes. The last error I got was that I had to implement IConvertible.<br></p> <p>I would prefer to use xml serialization because I can at least see it, is this possible for use by the designer?<br></p> <p>Is there a way to make the serialization more stable and less resistant to changes?</p> <p>Edit:<br> More information...better description maybe<br> I have a class which inherits from Component, it has one property which is a collection of Rules. The RulesCollection seems to have to be marked as Serializable, otherwise it does not retain its members.<br> </p> <p>The Rules class is also a Component with the attribute DesignTimeVisible(false) to stop it showing in the component tray, this clas is not marked Serializable.<br></p> <p>Having the collection marked as Serializable generates binary data in the resx file (not ideal) and the IDE reports that the Rules class is not Serializable.<br></p> <p>I think this issue is getting beyond a simple question. So I will probably close it shortly.<br> If anyone has any links to something similar that would help a lot.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload