Vijunav Vastivch
Vijunav Vastivch

Reputation: 4191

IServiceCollection Does not contain definition AddJsEngineSwitcher

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.

Upvotes: 4

Views: 4410

Answers (1)

Kirk Larkin
Kirk Larkin

Reputation: 93113

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;

Upvotes: 13

Related Questions