Webassembly Listbox NullReferenceException

I am trying to use the ListBox component in my Blazor Webassembly application. I am using Syncfusion.Blazor (19.2.0.55) and following (copy/paste) the example shown on the website here


I am running into an issue when the project starts up: 

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]

      Unhandled exception rendering component: Object reference not set to an instance of an object.

System.NullReferenceException: Object reference not set to an instance of an object.

  at Syncfusion.Blazor.DropDowns.SfListBox`2[TValue,TItem].OnAfterRenderAsync (System.Boolean firstRender) <0x48010e8 + 0x0053a> in <filename unknown>:0

  at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x4815c30 + 0x000b6> in <filename unknown>:0

>>>mono_wasm_get_loaded_files


Here is my code (copy/pasted from the example): 


Please let me know what I am missing or if there anything I should try and do. 


10 Replies

GK Gayathri KarunaiAnandam Syncfusion Team August 17, 2021 06:26 AM UTC

Hi Jacob, 

We have checked your reported query. We are unable to replicate the reported issue in our end. We have prepared a sample by using the Dual-List box documentation link. We suspect that the issue occurrence is due to not referring the ref property which is used to get the reference of the ListBox component. Please check the below code snippet. 

<div id="listbox1"> 
    <h4>Group A</h4> 
    <SfListBox TValue="string[]" DataSource="@GroupA" Scope="scope2" TItem="CountryCode" @attributes="listbox1Attr" @ref='ListBoxA'> 
        <ListBoxFieldSettings Text="Name"></ListBoxFieldSettings> 
        <ListBoxToolbarSettings Items="@Items"></ListBoxToolbarSettings> 
    </SfListBox> 
</div> 
<div id="listbox2"> 
    <h4>Group B</h4> 
    <SfListBox TValue="string[]" Scope="scope1" DataSource="@GroupB" TItem="CountryCode" @attributes="listbox2Attr" @ref='ListBoxB'> 
        <ListBoxFieldSettings Text="Name"></ListBoxFieldSettings> 
    </SfListBox> 
</div> 
 
 
@code { 
    SfListBox<string[], CountryCode> ListBoxA; 
    SfListBox<string[], CountryCode> ListBoxB; 
    private readonly Dictionary<string, object> listbox1Attr = new Dictionary<string, object> 
    { 
        { "id", "scope1" } 
    }; 
    private readonly Dictionary<string, object> listbox2Attr = new Dictionary<string, object> 
    { 
        { "id", "scope2" } 
    }; 
    public string[] Items = new string[] { "MoveUp", "MoveDown", "MoveTo", "MoveFrom", "MoveAllTo", "MoveAllFrom" }; 
    public List<CountryCode> GroupA = new List<CountryCode> 
    { 
        new CountryCode{ Name = "Australia", Code = "AU" }, 
        new CountryCode{ Name = "Bermuda", Code = "BM" }, 
        new CountryCode{ Name = "Canada", Code = "CA" }, 
        new CountryCode{ Name = "Cameroon", Code = "CM" }, 
        new CountryCode{ Name = "Denmark", Code = "DK" }, 
        new CountryCode{ Name = "France", Code = "FR" }, 
        new CountryCode{ Name = "Finland", Code = "FI" } 
    }; 
 
    public List<CountryCode> GroupB = new List<CountryCode> 
  { 
        new CountryCode{ Name = "India", Code = "IN" }, 
        new CountryCode{ Name = "Italy", Code = "IT" }, 
        new CountryCode{ Name = "Japan", Code = "JP" }, 
        new CountryCode{ Name = "Mexico", Code = "MX" }, 
        new CountryCode{ Name = "Norway", Code = "NO" }, 
        new CountryCode{ Name = "Poland", Code = "PL" }, 
        new CountryCode{ Name = "Switzerland", Code = "CH" } 
    }; 
 
    public class CountryCode 
    { 
        public string Name { get; set; } 
        public string Code { get; set; } 
    } 
} 
 
For your convenience, we have prepared a sample based on this. Please check the below sample. 


If you are still facing the issue, kindly share the below details. 

·        If possible, try to reproduce the reported issue in provided sample or share the issue reproducible sample.  
·        If possible, please share the video of the issue. 

Please provide the above requested information, based on that we will check and provide you a better solution quickly. 

Regards, 
Gayathri K 



JL Jacob Loncar replied to Gayathri KarunaiAnandam August 18, 2021 06:25 PM UTC

Copy and pasted code above still getting this error in browser:




I added the SfListBox items and set them to refs and still won't work. Please advise next steps. 



GK Gayathri KarunaiAnandam Syncfusion Team August 20, 2021 03:44 AM UTC

Hi Jacob, 

We have checked your query. We can reproduce your reported issue while we navigate between pages in our end. So, we have logged this issue as a bug, and it will be available in our upcoming patch release which will be scheduled on September 1st ,2021 and we appreciate your patience until then. 

You can also track the status of this bug by using our feedback portal link below.   
   
  
Please get back to us, if you need further assistance. 

Regards, 
Gayathri K 



GK Gayathri KarunaiAnandam Syncfusion Team September 7, 2021 04:08 AM UTC

Hi Jacob,  
  
Thanks for the patience.  
  
We have fixed your issue in our end and we have prepared custom Nuget package for this issue. Please find the Nuget link below.  
  
  
We suggest following below steps then upgrade our Syncfusion custom packages.   
  
·           Outdated custom scripts referred in the application.    
       
Also, could you please ensure the problem after clearing the browser/NuGet cache or run the application using incognito window of the browser.  We suggest you please delete all the folders inside C:\Users\UserName\.nuget\packages\syncfusion.blazor. And then install the given Nuget package in your application and check your issue.  
  
   

We would like to let you know that  we will move this fix in our upcoming patch release. 
  
Regards,  
Gayathri K 



GK Gayathri KarunaiAnandam Syncfusion Team September 9, 2021 03:01 AM UTC

Hi Jacob, 
 
Thanks for the patience. 
 
We are glad to announce that our weekly patch release (19.0.2.60) is rolled out. We have included the fix for your issue [ Listbox throws NullReferenceException while navigation ] in this release. So, we suggest you upgrade our Syncfusion packages to latest version to resolve this issue in your end. (19.0.2.60) 
 
 
 
Please let us know, if you need further assistance. 
 
Regards, 
Gayathri K 



JL Jacob Loncar replied to Gayathri KarunaiAnandam September 21, 2021 04:17 PM UTC

Thank you. There is no longer an error when using the Dual Listbox. However, now I can not move items from the Group B to Group A.


Also after moving an item from Group A to Group B, the item does not show up in the Group B listbox. 


The toolbar buttons only light up and allow me to click to move items when selecting an item in first listbox (left one).


Selecting an item from Group A allows me to move them up/down or move to Group B.



Selecting an item in Group B does nothing. The toolbar buttons don't light up and don't allow me to move the item up/down or move to Group A. 




I moved a couple of items from Group A to Group B and they disappear. The items are not found in Group B. 


The code is copied/pasted from here. I am using syncfusion package 19.2.0.62




GK Gayathri KarunaiAnandam Syncfusion Team September 22, 2021 08:46 AM UTC

Hi Jacob, 

We have checked your reported query in our 19.2.62 version.  

Query 1: Selecting an item in Group B does nothing. The toolbar buttons don't light up and don't allow me to move the item up/down or move to Group A.  

We have checked your reported issue in more cases. We are unable to replicate the reported issue in our end. Please check the below image. 

 
 
Query 2: I moved a couple of items from Group A to Group B and they disappear. The items are not found in Group B 
 
We have checked your reported issue in more cases. We are unable to replicate the reported issue in our end. Please check the below image. 

 
Please refer below code snippets. 
Code : 

 
<div id="listbox1"> 
    <h4>Group A</h4> 
    <SfListBox TValue="string[]" DataSource="@GroupA" Scope="scope2" TItem="CountryCode" @attributes="listbox1Attr"> 
        <ListBoxFieldSettings Text="Name"></ListBoxFieldSettings> 
        <ListBoxToolbarSettings Items="@Items"></ListBoxToolbarSettings> 
    </SfListBox> 
</div> 
<div id="listbox2"> 
    <h4>Group B</h4> 
    <SfListBox TValue="string[]" Scope="scope1" DataSource="@GroupB" TItem="CountryCode" @attributes="listbox2Attr"> 
        <ListBoxFieldSettings Text="Name"></ListBoxFieldSettings> 
    </SfListBox> 
</div> 
 
@code { 
    private readonly Dictionary<string, object> listbox1Attr = new Dictionary<string, object> 
    { 
        { "id", "scope1" } 
    }; 
    private readonly Dictionary<string, object> listbox2Attr = new Dictionary<string, object> 
    { 
        { "id", "scope2" } 
    }; 
    public string[] Items = new string[] { "MoveUp", "MoveDown", "MoveTo", "MoveFrom"}; 
    public List<CountryCode> GroupA = new List<CountryCode> 
    { 
        new CountryCode{ Name = "Australia", Code = "AU" }, 
        new CountryCode{ Name = "Bermuda", Code = "BM" }, 
        new CountryCode{ Name = "Canada", Code = "CA" }, 
        new CountryCode{ Name = "Cameroon", Code = "CM" }, 
        new CountryCode{ Name = "Denmark", Code = "DK" }, 
        new CountryCode{ Name = "France", Code = "FR" }, 
        new CountryCode{ Name = "Finland", Code = "FI" } 
    }; 
 
    public List<CountryCode> GroupB = new List<CountryCode> 
  { 
        new CountryCode{ Name = "India", Code = "IN" }, 
        new CountryCode{ Name = "Italy", Code = "IT" }, 
        new CountryCode{ Name = "Japan", Code = "JP" }, 
        new CountryCode{ Name = "Mexico", Code = "MX" }, 
        new CountryCode{ Name = "Norway", Code = "NO" }, 
        new CountryCode{ Name = "Poland", Code = "PL" }, 
        new CountryCode{ Name = "Switzerland", Code = "CH" } 
    }; 
 
    public class CountryCode 
    { 
        public string Name { get; set; } 
        public string Code { get; set; } 
    } 
} 
 
For your reference, we have prepared a sample based on your reported cases. Please check below link. 


We have created the video demonstration based on this. Please find the below video link. 


If you are still facing the issue, kindly share the below details. 

·        If possible, try to reproduce the reported issue in provided sample or share the issue reproducible sample.  
·        If possible, please share the video of the issue. 
·        If possible, Please the Listbox code snippets. 
 
Please provide the above requested information, based on that we will check and provide you a better solution quickly. 

Regards, 
Gayathri K 



JL Jacob Loncar September 22, 2021 04:32 PM UTC

Here is a video of my code that I am using. You can also see on the right what version of Syncfusion Blaxor I am running. Also another video of the problem I described.


Attachment: Vids_370d1673.zip



GK Gayathri KarunaiAnandam Syncfusion Team September 23, 2021 05:49 PM UTC

Hi Jacob, 

We have checked your reported query. We are unable to replicate the reported issue in our end. We need to validate more on this. So, we will update you the further details on September 24th, 2021. We appreciate your patience until then. 

Regards, 
Gayathri K 



GK Gayathri KarunaiAnandam Syncfusion Team September 24, 2021 11:20 AM UTC

Hi Jacob,  

We have created an incident for the above queries under your direct trac account, please follow that incident for further assistance.  


Regards,  
Gayathri K  


Loader.
Up arrow icon