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 error when deployed to production

I deployed Blazor server app to production server.
i have enbled error reporting with;
services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; });
This is what i am getting in the web console:
[2020-01-06T15:05:15.109Z] Error: 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.Calendars.EjsDatePicker`1.OnHybridInitialized()
at Syncfusion.EJ2.Blazor.Calendars.EjsDatePicker`1.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
Below app works ok on the development server

23 Replies

DN Dino Novak January 6, 2020 09:05 PM UTC

This is page on which error occures.
So the page is showing loading icon untill data is loaded in OnInitializedAsync() - I am doing multiple fetched to DB here so this takes a few seconds,
after that page should be refreshed and form with loaded data should be shown.

I suspect that due to page refresh (after all data is loaded) syncfusion service context is lost

Code for page:

@page "/seamanapplication2"

@using ApplicationShared.Models
@using ApplicationShared

@inject AppState _appState
@inject NavigationManager _uriHelper
@inject SeamanService _seamSvc

@if (seaman == null)
    <div class="sk-circle">
        <div class="sk-circle1 sk-child"></div>
        <div class="sk-circle2 sk-child"></div>
        <div class="sk-circle3 sk-child"></div>
        <div class="sk-circle4 sk-child"></div>
        <div class="sk-circle5 sk-child"></div>
        <div class="sk-circle6 sk-child"></div>
        <div class="sk-circle7 sk-child"></div>
        <div class="sk-circle8 sk-child"></div>
        <div class="sk-circle9 sk-child"></div>
        <div class="sk-circle10 sk-child"></div>
        <div class="sk-circle11 sk-child"></div>
        <div class="sk-circle12 sk-child"></div>

    <EjsDatePicker TValue="DateTime?"></EjsDatePicker>


    @code {

        Int32 SeamanId;
        Seaman seaman;
        protected IEnumerable<SeamanCertificateExtended> SeamanCertificates;

        protected override async Task OnInitializedAsync()

            if (_appState.UserName != null)
                SeamanId = _appState.UserID;
                seaman = await _seamSvc.GetSeaman(SeamanId);
                SeamanCertificates = await _seamSvc.GetSeamanCertificatesExtended(SeamanId);



RC Roberto Conti January 7, 2020 11:32 AM UTC

I'm in the same situation, the same error is raised from a page with an EjsGrid:

[2020-01-07T11:29:21.331Z] Error: 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.Grids.EjsGrid`1.OnHybridInitialized() at Syncfusion.EJ2.Blazor.Grids.EjsGrid`1.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

As with Dino, the app works on development machine but does not work on production server.

BC Berly Christopher Syncfusion Team January 7, 2020 01:47 PM UTC

Hi Dino,

Greetings from Syncfusion Support.

We have validated your scenario. Unfortunately, we could not able to reproduce the reported issue at our end. We have made sample for your convenience, please check the attached sample. If you are still facing the issue or if we misunderstood your query, please share below details to proceed further. 

  1. Issue reproducing sample
  2. If possible, try to reproduce the issue in the attached sample.
Berly B.C 

DN Dino Novak January 7, 2020 08:26 PM UTC

Dear support Team,

please find attached sample that is reproducing error behavior.
I added appstate and it looks like this is the reason. Please note that this will run OK on Win10 development machine, you need to publish it to server (in my case Win2016 Server)

Attachment: Datepicker_e0982e4f.zip

BC Berly Christopher Syncfusion Team January 8, 2020 02:18 PM UTC

Hi Dino, 
Please make use of the suggested solution in the below stack overflow link that the “RenderMode“ as “Server” instead of “ServerPrerendered” to get rid of the reported issue.  
Still the issue persists, please revert us with issue details that will help us to check and proceed further.  
Berly B.C 

DN Dino Novak January 8, 2020 02:44 PM UTC

Dear Support Team,
please note that suggested change _Host.cshtml did not fix the error, error is appearing again

this is change in _Hosts.cshtml

        <component type="typeof(App)" render-mode="Server" />


TO Tony January 9, 2020 03:57 AM UTC


I am also having similar problem.
Everything works fine when running on my local machine, but will get the NullReferenceException when I navigate to any page using SyncFusion control after deployed on server.
In my case, I am deploying it on Azure.
I have tried switching between Release mode and Debug mode on both environments, but the app deployed on Azure will crash regardless while working fine on local machine.

RC Roberto Conti January 9, 2020 08:50 AM UTC

still getting the same error here too.
This is the logged error (in addition to what previously reported from the browser console):

Unhandled exception in circuit 'IszWMcxJiZ3-QnYMWHpgf7Yi2ujvSX3OUjZ_tBeOjs0'.

System.ObjectDisposedException: Cannot access a disposed object.
   at Microsoft.AspNetCore.Components.RenderTree.ArrayBuilder`1.ThrowObjectDisposedException()
   at Microsoft.AspNetCore.Components.RenderTree.ArrayBuilder`1.GrowBuffer(Int32 desiredCapacity)
   at Microsoft.AspNetCore.Components.RenderTree.ArrayBuilder`1.Append(T[] source, Int32 startIndex, Int32 length)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

SN Sevvandhi Nagulan Syncfusion Team January 9, 2020 02:19 PM UTC

Hi Tony,   

We have checked hosting the sample in Azure and we are unable to reproduce the reported issue at our end. On the first page if you click on Login button, DatePicker will be rendered. On FetchData page, you can find the Grid. Kindly refer the below hosted link. 

If still issue persists, kindly revert us with below details that help us to proceed further. </