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

SfDiagram throws null pointer reference when using Shell navigation

Hi,

I use Shell navigation in my Xamarin forms project. I use sfDiagram to load organizational chart in the home screen. This works fine. After loading the diagram once, if I move to another page by using the Shell Flyout menu and come back to the home screen (again by using the Shell flyout menu), a null pointer reference is thrown. But none of the objects are null.

Steps to reproduce :

  1. Create Xamarin app with shell navigation.
  2. in the appshell.xaml, add two flyout items namely "Home1" and "Home2".
  3. Set the Shell content to redirect to home1.xaml and home2.xaml respectively. Home1 is the landing page of the application.
  4. Now in home1.xaml, add a sfdiagram and load an organizational chart.
  5. On the flyout menu, navigate to "Home2"
  6. Now come back to "Home1" again on the flyout menu.
  7. A null pointer reference is thrown.

Initially, the error was thrown in the beginnoderender event. In an attempt to avoid the event from firing and overcome the error, i cleared the sfDiagram (diagram.clear()) on the Disappearing event of the page.
Now the error is thrown when i try and load the organization chart again after moving back from Home2.xaml. 
The error occurs at :

diagram.datasourcesettings=settings;

I have verified that all the objects are proper and they are not null. This does not happen when i navigate to home2 by using 

shell.current.gotoasync ('...home2');

Below is the StackTrace:

  at Syncfusion.SfDiagram.Android.ConnectorCollection.Clear () [0x0008d] in <6b1ba4d23a10454c9a895553d4212f93>:0

  at Syncfusion.SfDiagram.Android.ConnectorCollection.Formconnectors_CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0014c] in <6b1ba4d23a10454c9a895553d4212f93>:0

  at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)

  at Syncfusion.SfDiagram.XForms.ConnectorCollection.OnConnectors_CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00008] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Syncfusion.SfDiagram.XForms.ConnectorCollection.Clear () [0x0001e] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Syncfusion.SfDiagram.XForms.SfDiagram.Clear () [0x0000e] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Syncfusion.SfDiagram.XForms.DataSourceSettings.UpdateLayoutDataSource () [0x0000b] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Syncfusion.SfDiagram.XForms.DataSourceSettings.UpdateDataSource (Syncfusion.SfDiagram.XForms.SfDiagram diagram) [0x00007] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Syncfusion.SfDiagram.XForms.DataSourceSettingsController..ctor (Syncfusion.SfDiagram.XForms.DataSourceSettings source, Syncfusion.SfDiagram.XForms.SfDiagram diagram) [0x00015] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Syncfusion.SfDiagram.XForms.SfDiagram.OnDataSourceSettingsChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00003] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:512

  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446

  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0004d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:374

  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:349

  at Syncfusion.SfDiagram.XForms.SfDiagram.set_DataSourceSettings (Syncfusion.SfDiagram.XForms.DataSourceSettings value) [0x00000] in <bffdc7e46baa4d6a99ade728d1e51330>:0

  at Salesboard.Dashboard.GetMyReportees () [0x00199] in E:\Source code\SFA2.0\R2.0.7\Salesboard\Dashboard.xaml.cs:77


Thanks

Santhosh



10 Replies

HD Hemalatha Duraisamy Syncfusion Team October 17, 2022 12:52 PM

Hi Santhosh Kumar,


Greetings from Syncfusion support, 

We were able to reproduce the issue, “SfDiagram throws null pointer reference when using Shell navigation".

Currently, we are validating the issue and we will update the further details on 19th October 2022.

Regards

Hemalatha D.



HD Hemalatha Duraisamy Syncfusion Team October 19, 2022 11:52 AM

Hi Santhosh Kumar,


We have confirmed that the issue with "SfDiagram throws null pointer reference when using Shell navigation". is a defect and have logged a defect report for this issue. The fix for the issue will be include in our upcoming weekly NuGet published under nuget.org and it is expected to be available on 2nd November 2022.


Feedback Link:  https://www.syncfusion.com/feedback/38561/sfdiagram-throws-null-reference-exception-when-using-shell-navigation

  

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”


Regards,

Hemalatha D.




SK Santhosh Kumar replied to Hemalatha Duraisamy November 8, 2022 11:45 PM

Hi,


Has this been released?


Thanks


Santhosh



HD Hemalatha Duraisamy Syncfusion Team November 9, 2022 09:19 AM

We have included the SfDiagram throws null pointer reference when using Shell navigation in our 2022 Volume 3 Service Pack Release V20.3.0.56


We are glad to announce that our Essential Studio 2022 Volume 3 Service Pack Release V20.3.0.56 is rolled out and is available for download under the following link.


https://www.syncfusion.com/forums/178709/essential-studio-2022-volume-3-service-pack-release-v20-3-0-56-is-available-for-download


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.



SK Santosh Kumar replied to Hemalatha Duraisamy November 11, 2022 01:46 AM

Hi Hemalatha,


Unfortunately, I still have problem after updating the new version but this time, the stack trace looks different.

Please have a look into it.


  at Syncfusion.SfDiagram.Android.Node.get_Frame () [0x00006] in <b24d3201759a4ea4981d832101fbeb53>:0

  at Syncfusion.SfDiagram.Android.Node.set_Width (System.Single value) [0x0004d] in <b24d3201759a4ea4981d832101fbeb53>:0

  at Syncfusion.SfDiagram.Android.Node.OnNodePropertiesChanged (System.String propertyName) [0x00038] in <b24d3201759a4ea4981d832101fbeb53>:0

  at Syncfusion.SfDiagram.Android.Node.Formnode_PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00007] in <b24d3201759a4ea4981d832101fbeb53>:0

  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)

  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266

  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510

  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446

  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0004d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:374

  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:349

  at Syncfusion.SfDiagram.XForms.Node.set_Width (System.Single value) [0x00000] in <985f2af6fe644b02b97cc0fc4acddfd8>:0

  at Salesboard.Dashboard.diagram_BeginNodeRender (System.Object sender, Syncfusion.SfDiagram.XForms.BeginNodeRenderEventArgs args) [0x00019] in E:\Source code\SFA2.0\R2.0.7\Salesboard\Dashboard.xaml.cs:478

  at Syncfusion.SfDiagram.XForms.SfDiagram.OnBeginNodeRenderChanged (Syncfusion.SfDiagram.XForms.BeginNodeRenderEventArgs e) [0x00008] in <985f2af6fe644b02b97cc0fc4acddfd8>:0

  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)

  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395



Thanks


Santhosh



SK Santhosh Kumar replied to Santosh Kumar November 11, 2022 02:11 AM

Below is the block where it fails.


 private void diagram_BeginNodeRender(object sender, BeginNodeRenderEventArgs args)

        {

            var node = (args.Item as Node);

            if (node != null)

            {

                node.ShapeType = ShapeType.RoundedRectangle;

                node.Width = 150; ---------------------------error thrown at this line

                node.Height = 230;

                SiblingSpace siblingSpacing = new SiblingSpace(5, 5);

                node.SiblingSpace = siblingSpacing;

                UpdateTemplate(node, "-");

            }


        }



HD Hemalatha Duraisamy Syncfusion Team November 14, 2022 11:19 AM

We tried to reproduce the reported issue, but it is working fine as expected.


We have created a sample based on the provided code snippets and the sample and video can be downloaded from the below link. 


Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfDiagram-1235510547


Video Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Diagram2024436441


Provide the following details to investigate further on this issue.  

  1. Modify / Simple sample in which the issue was reproduced.
  2. Replication procedure to reproduce the issue or screen shot illustrating the issue.

The above details will be more helpful for us to reproduce the issue in our side and assist you with the better solution at the earliest.  




SK Santhosh Kumar November 15, 2022 01:18 AM

Hi Hema,


The steps to reproduce are same as given earlier.

I have provided by code as well in the attached file along with a screenshot  (refer to the word doc) of the line where it fails. The original problem reported also failed on the same line.

The stack trace looks to be different from the original problem reported though.


Thanks


Santhosh


Attachment: Diagram_42b2a471.zip


HD Hemalatha Duraisamy Syncfusion Team November 16, 2022 11:27 AM

We tried to reproduce the reported issue. But it is working fine as expected.
  

We have created a sample based on the provided code snippets the sample can be downloaded from the below link.

https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfDiagram-614065192


However, we suspect that the issue may occur due to the older assemblies are still referred from GAC location. Can you cross check and remove the assemblies from GAC location. Find the link to remove the Syncfusion assemblies from GAC. 

https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache 


For further details, Find the steps to remove old assemblies from GAC and install the patch by using Syncfusion Assembly Manager,  

https://www.syncfusion.com/kb/7509/how-to-install-and-remove-syncfusion-essential-studio-assemblies-from-gac    


Still, you are facing the issue we will setup a web meeting to look into the problem in that machine with which it could be reproduced and provide you the solution. Please let us know your availability. We will make every effort to have this scheduled on a date and time of your convenience.





SK Santhosh Kumar replied to Hemalatha Duraisamy November 17, 2022 02:21 AM

Hi Hema,


It works fine now after clearing the Nuget cache. 


Thank you very much for your support.


Santhosh


Loader.
Live Chat Icon For mobile
Up arrow icon