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

Runtime exception on ASP.Net Core 3.1

Hello:
I have a solution currently working on ASP.Net Core 3.0 and I am trying to upgrade to version 3.1.
When I run the solution on ASP.Net Core 3.1 and try to load a page that uses Syncfusion Radio Button control (version 17.4.0.40) I get this exception:
"fail: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[7]
      An exception was thrown while deserializing the token.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The antiforgery token could not be decrypted.
 ---> System.Security.Cryptography.CryptographicException: The key {981d8ed0-8398-43ec-af23-af840a4d7f21} was not found in the key ring.
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte[] protectedData, Boolean ignoreRevocationErrors, Boolean& requiresMigration, Boolean& wasRevoked)
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
   at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)
   at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.GetCookieTokenDoesNotThrow(HttpContext httpContext)
warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[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.EJ2.Blazor.SyncfusionBlazorService.GetContext()
   at Syncfusion.EJ2.Blazor.BaseComponent.OnInitializedAsync()
   at Syncfusion.EJ2.Blazor.Buttons.EjsRadioButton.OnHybridInitialized()
   at Syncfusion.EJ2.Blazor.Buttons.EjsRadioButton.OnInitializedAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'WxsRgttdZDc4q1mqMZAG7_MSfeds-vtHt0HLazEA--0'.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Syncfusion.EJ2.Blazor.SyncfusionBlazorService.GetContext()
   at Syncfusion.EJ2.Blazor.BaseComponent.OnInitializedAsync()
   at Syncfusion.EJ2.Blazor.Buttons.EjsRadioButton.OnHybridInitialized()
   at Syncfusion.EJ2.Blazor.Buttons.EjsRadioButton.OnInitializedAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      Unhandled exception rendering component: Cannot access a disposed object.
      Object name: 'IServiceProvider'.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'IServiceProvider'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass5_0.<CreateInitializer>g__Initialize|2(IServiceProvider serviceProvider, IComponent component)
   at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServ"


3 Replies

SD Saranya Dhayalan Syncfusion Team January 2, 2020 12:43 PM UTC

Hi ERDASA, 
  
Good day to you. 
  
We have checked your issue. We are not able to reproduce it in our end. Before we start to work with this, we would like to know the following details, 
  
1.       Please share code snippets of the page which causes the exception. 
2.       If possible, please replicate your issue in the below attached sample. 
  
We have prepared a sample with radio button, please refer the below sample link whether the sample resolve your issue. 
  
 
Please refer the below documentation link: 
 
  
Regards, 
Saranya D 



ER ERDASA January 2, 2020 04:27 PM UTC

Hello:
Thanks for the sample code.  I was missing these lines in Startup.cs:

            services.AddAntiforgery();
            services.AddDataProtection();

Everything is working fine now. 
I would suggest to add these lines to the section that refers to Startup.cs in the Getting Started documentation.

  1. Open the ~/Startup.cs file and register the Syncfusion Blazor Service.

    using Syncfusion.EJ2.Blazor;
    
    namespace WebApplication1
    {
        public class Startup
        {
            public void ConfigureServices(IServiceCollection services)
            {
                ....
                ....
                services.AddSyncfusionBlazor(); }
        }
    }

Best regards,
Hans Kühlmann


SD Saranya Dhayalan Syncfusion Team January 3, 2020 05:18 AM UTC

Hi ERDASA 
 
Most Welcome. 
 
We have already added the lines in the How-To section(Troubleshoot). Please find the below documentation link 
 
 
Please let us know, if you need any further assistance on this.  
 
Regards, 
Saranya D 


Loader.
Live Chat Icon For mobile
Up arrow icon