I have a problem when adding hyperlink to a shape in a VSD template file with the latest version of Aspose.Diagram for .NET (version 25.11.0). I am using C# with .NET Framework 4.8 (in Visual Studio 2022, latest version) on Windows 11 x64. This issue does not occur with version 25.5.0 of the package Aspose.Diagram for .NET (because of this issue we cannot use the latest version of the package Aspose.Diagram for .NET).
Summary
You are encountering a System.NullReferenceException when calling shape.Hyperlinks.Add(...) on a shape loaded from a VSD template using Aspose.Diagram .NET 25.11.0. The same code works with version 25.5.0, which indicates a regression or a change in the way the newer library handles the Hyperlinks collection.
Why it happens
The evidence available does not contain a specific description of this issue for Aspose.Diagram 25.11.0, so we cannot point to a documented bug or a known change in behavior. However, the symptom (the Hyperlinks property being null) typically occurs when the SDK does not automatically instantiate the HyperlinkCollection for a shape that originally has no hyperlinks. In earlier versions the collection was created lazily, which prevented the NullReferenceException.
What to do next
Confirm the null collection
using Aspose.Diagram;
var diagram = new Diagram("yourTemplate.vsd");
var shape = diagram.Pages[0].Shapes[0];
if (shape.Hyperlinks == null)
Console.WriteLine("Hyperlinks collection is null – appears in 25.11.0");
else
Console.WriteLine("Hyperlinks collection is instantiated");
Run this with both 25.5.0 and 25.11.0 to verify the regression.
Apply a safe workaround
if (shape.Hyperlinks == null)
shape.Hyperlinks = new HyperlinkCollection(); public setter exists
shape.Hyperlinks.Add(new Hyperlink { Address = " });
Initialising the collection manually prevents the exception.
Report the issue to Aspose
Prepare a minimal reproducible sample (the VSD file that triggers the exception and the exact line of code).
Submit the sample through the Aspose support portal or the internal channel you normally use.
Mention the version regression (25.5.0 works, 25.11.0 fails) so the product team can prioritize a fix.
Temporary mitigation
Continue using version 25.5.0 in production if the manual collection initialisation is not acceptable for your code base.
Alternatively, convert the VSD file to an intermediate format (e.g., VDX) and reload it; this often forces the SDK to rebuild the shape model and may populate the Hyperlinks collection automatically.
Provide additional details if needed
The shape type (rectangle, connector, group, etc.)
Whether the shape is part of a group or a master page
Any custom properties that might affect shape loading
If you implement the collection‑initialisation and still see the exception, please share the extra details above so we can investigate further.
Note: The current evidence does not contain a direct reference to this specific issue, so the above steps are based on typical SDK behavior and best‑practice troubleshooting.
I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.
@tkn1967
Thanks for the template file and screenshots.
After an initial testing, I am able to reproduce the issue as you mentioned by using your template file.We apologize for any inconvenience caused.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): DIAGRAMNET-53843
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.