3
votes

Trying to build ReactJS.NET in Visual Studio 2015

using Microsoft.AspNetCore.Http;
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.ChakraCore;
using React.AspNet;

In ConfigureServices

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddApplicationInsightsTelemetry(Configuration);

    services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
    services.AddReact();

    services.AddJsEngineSwitcher(options => options.DefaultEngineName = ChakraCoreJsEngine.EngineName)
        .AddChakraCore();

     services.AddMvc();
}

Got an Error to this part:

AddJsEngineSwitcher

IServiceCollection does not contain definition for AddJsEngineSwitcher

Trying to fix some solutions but got no luck.

Checking also my Reference

JavaScriptEngineSwitcher 3.0.0 is exists.

Also searching in Nuget package and changed JavaScriptEngineSwitcher but still the same.

I am using .NET Framework 4.6.

1

1 Answers

6
votes

The docs show that you need to install this NuGet package, which contains the AddJsEngineSwitcher extension method that's missing:

JavaScriptEngineSwitcher.Extensions.MsDependencyInjection

Once installed, you'll also need to add the following using to include the namespace:

using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;