Skip to content

NullReferenceException at React.AspNet.HttpContextLifetimeProvider.get_Registrations() during Startup #814

Closed
@kurtcodemander

Description

@kurtcodemander

Please verify these steps before filing an issue, and check them off as you go

  • The relevant native JavascriptEngineSwitcher library packages are installed (such as JavaScriptEngineSwitcher.V8.Native.win-x64)
  • The VC++ 2017 runtime is installed
  • The value of SetUseReact and SetUseBabel is correct in ReactConfig.cs or Startup.cs
  • I've looked at the sample projects in this repo to verify that my app is configured correctly

I'm using these library versions:

  • ReactJS.NET: 4.2.0-beta1
  • JavaScriptEngineSwitcher: 3.1.1
  • react and react-dom: N/A
  • webpack: N/A
  • node: N/A
  • JavaScriptEngineSwitcher.V8.Native.win-x64

Runtime environment:

  • OS: Windows 2016 DataCenter, 64-bit
  • .NET Framework 4.7.2

VS 2019 Build Tools workloads installed in Azure Service Fabric VMs:

  • Microsoft.VisualStudio.Workload.MSBuildTools
  • Microsoft.VisualStudio.Workload.NetCoreBuildTools
  • Microsoft.VisualStudio.Workload.NodeBuildTool
  • Microsoft.VisualStudio.Workload.WebBuildTools --includeRecommended --quiet
  • Microsoft.Net.Component.4.6.2.SDK
  • Microsoft.Net.Component.4.6.2.TargetingPack
  • Microsoft.Net.Component.4.7.1.SDK
  • Microsoft.Net.Component.4.7.1.TargetingPack
  • Microsoft.Net.Component.4.7.2.SDK
  • Microsoft.Net.Component.4.7.2.TargetingPack

I'm trying to run my ASP.NET Core project, running under .NET Framework 4.7.2, to run in Azure Service Fabric. However I'm getting System.NullReferenceException at React.AspNet.HttpContextLifetimeProvider.get_Registrations() , when running app.UseReact(...).

The exception looks similar to #600 [Rendering without HTTPContext]

It works in Azure Service Fabric on my development computer, but I cannot for the life of me figure out what's wrong in Azure or what's missing in the VMs.

Startup.cs, ConfigureServices contains this code before call to services.AddMvc(...):

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddReact();
services.AddJsEngineSwitcher(options => options.DefaultEngineName = ChakraCoreJsEngine.EngineName).AddChakraCore();

Startup.cs, Configure contains this code (no custom configuration) before call to app.UseStaticFiles();:

app.UseReact(config =>{});

I've tried changing

void ConfigureServices(...)

to

IServiceProvider ConfigureServices(...)
...
return return services.BuildServiceProvider();

Any tips on how to hunt this down?

Exception:

System.RA' reported Warning for property 'ReplicaOpenStatus'. Replica had multiple failures during open on _Primary_0. API call: IStatelessServiceInstance.Open(); Error = System.NullReferenceException (-2147467261) Object reference not set to an instance of an object.
at React.AspNet.HttpContextLifetimeProvider.get_Registrations()
at React.AspNet.HttpContextLifetimeProvider.ReleaseObject()
at React.TinyIoC.SafeDictionary2.set_Item(TKey key, TValue value)
at React.TinyIoC.TinyIoCContainer.RegisterRegisterType,RegisterImplementation
at React.AssemblyRegistration.Register(TinyIoCContainer container)
at React.Initializer.InitializeIoC(Func2 requestLifetimeRegistration)
at React.AspNet.ReactBuilderExtensions.UseReact(IApplicationBuilder app, Action`1 configure, BabelFileOptions fileOptions) at AdminWeb.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\CloudIDE\Workspaces\Codemander\Azure Service Fabric\AdminWeb\Startup.cs:line 1082
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Microsoft.ServiceFabric.Services.Communication.AspNetCore.AspNetCoreCommunicationListener.OpenAsync(CancellationToken cancellationToken)
at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__13.MoveNext()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions