We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding custom property makes Diagram crash and document file corrupt

Hi, we just add a custom property and when we attempt to save resulting document then Aspose.Diagram crashes in exception and original document file becomes corrupt. The file cannot be opened by Aspose.Diagram or MS Visio.



I have added a .zip file containg sample code and crash report.



Test file and output file are also attached. We used Aspose.Diagram version: 17.1.0.0



Any help is highly appreciated.



Thanks and kind regards

Sven Andersen

Hi Sven,


Thank you for contacting Aspose support.

As per my testing, the said problem is caused due to the fact that you are not assigning the CustomProp.Name property, therefore the custom property remains nameless and hence cause the NullReferenceException. Please check the updated RefineSetProp method as follow, and give it a try on your side.

Please note, I have tested the scenario against the latest version of Aspose.Diagram for .NET 17.1.1 (attached) to get the correct result (attached).

C#
static void RefineSetProp(Aspose.Diagram.Diagram document, string name, string value)
{
Aspose.Diagram.CustomPropCollection customProperties = document.DocumentProps.CustomProps;
for (int i = 0; i < customProperties.Count; i++)
{
if (String.Compare(customProperties[i].Name, name, true) == 0)
customProperties.Remove(customProperties[i]);
}
Aspose.Diagram.CustomProp customProp = new Aspose.Diagram.CustomProp();
customProp.Name = name;
customProp.PropType = Aspose.Diagram.PropType.String;
customProp.CustomValue.ValueString = value;
customProperties.Add(customProp);
}

Hi Babar, many many thanks. Yes this is clearly our mistake. We have corrected our application according to your correction.

PS. Maybe Diagram could be improved so that such mistake gives clear exception cause, and not a corrupt file.

Thanks, and kind regards
Sven Andersen

Hi Sven,

HIGHSTAGE:
Yes this is clearly our mistake. We have corrected our application according to your correction.

Thank you for the confirmation on proposed solution. It is good to know that you are up & running again.

HIGHSTAGE:
Maybe Diagram could be improved so that such mistake gives clear exception cause, and not a corrupt file.

Your concerns make sense therefore I have forwarded these concerns to the product team by logging a formal request as DIAGRAMNET-51149. Please spare us little time to properly analyze the case and revert back with updates in this regard.

Hi again,


This is to update you that the ticket logged earlier as DIAGRAMNET-51149 has been marked resolved. Please note, once the fix is available for your testing, you will be able to generate the correct document without any exception regardless of the fact if you assign the CustomProp.Name property or not.

Hi Babar, thanks for super good response to my problems.
Thanks and kind regards
Sven Andersen

Hi Sven,


You are most welcome. Please feel free to contact us back in case you need our further assistance with Aspose APIs.

The issues you have found earlier (filed as DIAGRAMNET-51149) have been fixed in Aspose.Diagram for .NET 17.02.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.