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

I am trying to minimize my .JSX files using ASP.NET optimization and optimization using System.Web.Optimization.React. I installed the MVC4 response package as well as the optimization package, but whenever I try to include the package, I get the following:

React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment

InnerException is always null

My packages are installed as follows:

bundles.Add(new ScriptBundle("~/Bundle/Scripts/ReactJS").Include(
                "~/Scripts/React/react-0.12.2.js",
                "~/Scripts/React/react-with-addons-0.12.2.js",
                "~/Scripts/React/JSXTransformer-0.12.2.js"
            ));

        bundles.Add(new JsxBundle("~/Bundle/Scripts/ReactCalendar").Include(
                "~/Scripts/React/Calendar/Main.react.jsx",
                "~/Scripts/React/Calendar/Components/Calendar.react.jsx",
                "~/Scripts/React/Calendar/Components/CalendarEvent.react.jsx",
                "~/Scripts/React/Calendar/Components/CalendarControls.react.jsx",
                "~/Scripts/React/Calendar/Components/CalendarTimeSlots.react.jsx"
            ));

And included in the presentation as:

@section scripts{
    @Scripts.Render("~/Bundle/Scripts/ReactJS");
    @Scripts.Render("~/Bundle/Scripts/ReactCalendar");
}

The error is always displayed on the line:

@Scripts.Render("~/Bundle/Scripts/ReactCalendar");

Anyone have any ideas on how to solve / debug this one? Let me know if additional information is needed.

+5
source share
3 answers

" : React.IReactEnvironment" InnerException, , , ReactJS.NET - . - ReactJS.NET WebActivator. , React.Web, React.Web.Mvc4 WebActivatorEx, DLL bin.

, ( ) JSXTransformer JavaScript, ReactJS.NET JSX .

+4

, , , , SO , , .


.NET 4.5 MVC React.Web.Mvc4 v3.0.0.

Github.

ReactConfig.cs:

using React;
using React.TinyIoC;
using React.Web.TinyIoC;

namespace NS.Project
{
    public static class ReactConfig
    {
        public static void Configure()
        {
            Initializer.Initialize(AsPerRequestSingleton);

            ReactSiteConfiguration.Configuration
                .SetLoadBabel(false)
                .AddScriptWithoutTransform("~/React/dist/server.bundle.js");
        }

        private static TinyIoCContainer.RegisterOptions AsPerRequestSingleton(
            TinyIoCContainer.RegisterOptions registerOptions)
        {
            return TinyIoCContainer.RegisterOptions.ToCustomLifetimeManager(
                registerOptions,
                new HttpContextLifetimeProvider(),
                "per request singleton"
            );
        }
    }
}

ReactConfig.Configure Application_Start.

+3

React.Web.MVc4 4.0.0. .

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

To use V8, add the following packages:

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

ReactConfig.cs will be automatically created for you. Update it to register the 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();
        }
    }
}
0
source

All Articles