6

I'm in the process of creating a basic .NET Core 2.0 App

[New]-[Project]-[.NET Core]->[ASP.NET Core Web Application (.NET Core)]-[Web Application (No Auth)]

and trying to add ReactJS by following the tutorial here: (https://reactjs.net/getting-started/tutorial.html)

When going through the tutorial, however, I get an "InvalidOperationException" error that says: 'Cannot resolve scoped service 'React.AspNet.HttpContextLifetimeProvider+PerRequestRegistrations' from root provider.'

Specifically the error comes from the app.UseReact(config=> ... ) section of the tutorial.

Despite my many searches both here and abroad I've come empty-handed, so I reach out to you all here. If this is referenced or already resolved here, please let me know as well.

I'm hoping I'm just overlooking something here.

Assumptions:



Update:

It turns out the problem was that there was a mismatch between the version of React that I had previously installed, and the Visual Studio Project's stated React version.
The solution was a simple reinstall of React via the command line to align with the project.

Thanks for all the help!

  • Note: I was using .net core 2.0 preview1 instead of preview2, which offers React.js templates (and so bypasses the problem). Will follow up some time later about this particular issue though. – WaldoFoundGodot Jul 26 '17 at 21:37
  • Any news? I'm having the same issue using VS2017.3 preview 7.1 with core 2.0 final – Sinaesthetic Aug 13 '17 at 20:47
  • Oh I updated a package for aspnetcore 2.0 final and that error went away. The started getting some other error about diagnostic source. So I updated to the latest CLI and that problem went away but now the original one is back D: – Sinaesthetic Aug 13 '17 at 21:12
  • got you a hit @ https://github.com/reactjs/React.NET/issues/433 – BozoJoe Aug 27 '17 at 01:18

1 Answers1

15

see https://github.com/reactjs/React.NET/issues/433

change in Startup.cs

public void ConfigureServices(IServiceCollection services)

to

public IServiceProvider ConfigureServices(IServiceCollection services)

and return services.BuildServiceProvider();

I also had to update/upgrade my node to c6.11.2 (via MSI), but I dont think thats related to your problem.

BozoJoe
  • 6,117
  • 4
  • 44
  • 66