ReactJS.NET - Bundles - TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment

后端 未结 3 2238
心在旅途
心在旅途 2020-12-20 17:12

I\'m attempting to minify my .JSX files with ASP.NET Minification and Optimization via System.Web.Optimization.React. I\'ve installed the MVC4 React Package as well as the O

3条回答
  •  鱼传尺愫
    2020-12-20 18:17

    Something looks like changed from React.Web.MVc4 version 4.0.0. versions before didnt have that problem.

    as stated here

    Install the React.Web.Mvc4 package through NuGet. You will also need to install a JS engine to use (either V8 or ChakraCore are recommended). See the JSEngineSwitcher docs for more information.

    To use V8, add the following packages:

    JavaScriptEngineSwitcher.V8
    JavaScriptEngineSwitcher.V8.Native.win-x64
    

    ReactConfig.cs will be automatically generated for you. Update it to register a JS engine and your JSX files:

    using JavaScriptEngineSwitcher.Core;
    using JavaScriptEngineSwitcher.V8;
    
    [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(React.Sample.Mvc4.ReactConfig), "Configure")]
    
    namespace React.Sample.Mvc4
    {
        public static class ReactConfig
        {
            public static void Configure()
            {
                ReactSiteConfiguration.Configuration
                    .AddScript("~/Content/Sample.jsx");
    
                JsEngineSwitcher.Current.DefaultEngineName = V8JsEngine.EngineName;
                JsEngineSwitcher.Current.EngineFactories.AddV8();
            }
        }
    }
    

提交回复
热议问题