WaldoFoundGodot
WaldoFoundGodot

Reputation: 73

Setting Up ReactJS on .NET Core 2.0, InvalidOperationException

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!

Upvotes: 6

Views: 2574

Answers (1)

BozoJoe
BozoJoe

Reputation: 6462

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.

Upvotes: 15

Related Questions