We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

serialization

Hi, I am having trouble loading a diagram with some custom labels added to the symbols. The project is based on the sample DiagramBuilder project. I have implemented a number of wrapper classes: PEPDiagram : Diagram PEPModel : Model PEPSymbolLabel : SymbolModel I believe I have implemented the necessary methods for serialization of the new properties added to the classes. I can save and load a diagram when my symbols DO NOT contain PEPSymbolLabels. However, when I add a PEPSymbolLabel I CAN save it, but when I attempt to open the save diagram I get an error: Serialization error - Exception has been thrown by the target of an invocation. I then get an exception: //---- An unhandled exception of type ''System.NullReferenceException'' occurred in DiagramBuilder.exe Additional information: Object reference not set to an instance of an object. //---- When I step through the code, the serialization is attempting to set the value of the PEPSymbolLabel.ReadOnly property, it is at this point that the exception is raised. It is almost as if there is no instance of PEPSymbolLabel before it attempts to set the property. I have attached my source code. Any help would be much appreciated. Am newbie to C# so I suspect that I am doing something daft! Thanks for you quick response in previous posts. Jimski PE3 Demo_8403.zip

4 Replies

JB James Brock September 23, 2004 06:07 AM UTC

Further to my post I have been working on this issue. I seem to have come upon a work around, although I still suspect that it is something I am doing. In my LabelType set routine I am setting such properties as ReadOnly, Anchor etc... which I use when I create the SymbolLabel. However, these are being called during serialization and subsequently cannot be set, as I assume the object has not been instantiated at that time? My work around is to set a flag in the serialization constructor: protected PEPSymbolLabel(SerializationInfo info, StreamingContext context) : base(info, context) { boolDeserialising = true; LabelType = (LabelTypes) info.GetUInt16 boolDeserialising = false; } Now when the LabelType set routine is called I check if bool Deserializing is True and do not set the properties. Is there a more generic way of doing this, or even a best practice when using my set routine? Cheers Jimski


AD Administrator Syncfusion Team September 23, 2004 04:13 PM UTC

Hi Jimski I tried running the sample and I could not reproduce the problem. Can you post a stripped down version (without the splash screen, to save some time :-)) along with steps to reproduce the problem. Also, can you take a look at the sample I posted in this forms post which demonstrates how a Custom Symbol can be serialized as this is what you are trying to do. Thanks for your cooperation and continued support for Syncfusion. Regards Arun


JB James Brock September 24, 2004 08:05 AM UTC

Hi Arun, Am getting on better now and have looked at your example. Don''t suppose you can remove the source zip from my original post could you? Thought I had posted a version without the splash, but obviously not! Jimski


AD Administrator Syncfusion Team September 24, 2004 09:35 AM UTC

Hi Jimski Thanks for the update. Kindly update this posting if you have any further questions. Regards Arun

Loader.
Live Chat Icon For mobile
Up arrow icon