【问题标题】:IServiceCollection Does not contain definition AddJsEngineSwitcherIServiceCollection 不包含定义 AddJsEngineSwitcher
【发布时间】:2019-06-09 05:06:57
【问题描述】:

尝试在 Visual Studio 2015 中构建 ReactJS.NET

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

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();
}

这部分出错了:

AddJsEngineSwitcher

IServiceCollection 不包含 AddJsEngineSwitcher 的定义

尝试修复一些解决方案但没有成功。

检查我的参考资料

JavaScriptEngineSwitcher 3.0.0 存在。

也在 Nuget 包中搜索并更改了JavaScriptEngineSwitcher,但仍然相同。

我正在使用 .NET Framework 4.6。

【问题讨论】:

    标签: c# asp.net-core


    【解决方案1】:

    docs 表明您需要安装此 NuGet 包,其中包含缺少的 AddJsEngineSwitcher 扩展方法:

    JavaScriptEngineSwitcher.Extensions.MsDependencyInjection

    安装后,您还需要添加以下 using 以包含命名空间:

    using JavaScriptEngineSwitcher.Extensions.MsDependencyInjection;
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-03
    • 1970-01-01
    • 2020-04-02
    • 1970-01-01
    • 2019-04-14
    • 2016-09-25
    • 2020-08-20
    • 1970-01-01
    相关资源
    最近更新 更多