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!

4
  • 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. Commented Jul 26, 2017 at 21:37
  • Any news? I'm having the same issue using VS2017.3 preview 7.1 with core 2.0 final Commented Aug 13, 2017 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: Commented Aug 13, 2017 at 21:12
  • got you a hit @ github.com/reactjs/React.NET/issues/433 Commented Aug 27, 2017 at 1:18

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.