Blazor.Diagrams icon indicating copy to clipboard operation
Blazor.Diagrams copied to clipboard

NullReferenceException when removing DrawNewLinkBehavior

Open GeertvanHorrik opened this issue 1 year ago • 1 comments

I was getting NullReferenceExceptions when updating to the new 3.x version. After some debugging, I noticed the ignoring of potentially nullable value:

https://github.com/Blazor-Diagrams/Blazor.Diagrams/blob/develop/src/Blazor.Diagrams/Components/LinkWidget.razor#L18

Since the behavior can be removed, the null check should still exist?

For now I disabled this call on new diagrams:

diagram.UnregisterBehavior<DragNewLinkBehavior>();

GeertvanHorrik avatar Feb 29 '24 11:02 GeertvanHorrik

I had the same exception by removing DrawNewLinkBehavior and registering a derived class from it. I solved the issue by changing the GetBehavior function to check if has a derived class if the asked is not found.

vbalestone avatar Apr 23 '24 19:04 vbalestone