本文介绍了ReactJS.NET-捆绑包-TinyIoCResolutionException:无法解析类型:React.IReactEnvironment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正尝试通过System.Web.Optimization.React使用ASP.NET最小化和优化来最小化.JSX文件.我已经安装了MVC4 React软件包以及Optimization软件包,但是每当尝试包含一个软件包时,我都会得到以下信息:

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 Optimization package, but whenever I try to include a bundle I get the following:

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

InnerException始终为null

The InnerException is always null

我的捆绑软件设置如下:

My bundles are setup 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"
            ));

并在视图中包含为:

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

错误总是在线上引发:

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

任何人都对如何解决/调试此问题有任何想法?让我知道是否需要更多信息.

Anyone got any ideas on how to solve / debug this one? Let me know if more info is needed.

推荐答案

"无法解析类型:React.IReactEnvironment ,没有InnerException,通常意味着ReactJS.NET由于某种原因未正确初始化.在Web应用程序中,ReactJS.NET通过使用 WebActivator 来处理初始化.确保您的项目引用了React.WebReact.Web.Mvc4WebActivatorEx,并且所有相应的.dll文件都位于应用程序的bin目录中.

"Unable to resolve type: React.IReactEnvironment" with no InnerException generally means ReactJS.NET is not initialising properly for some reason. In web apps, ReactJS.NET handles initialisation through the use of WebActivator. Make sure your project is referencing React.Web, React.Web.Mvc4 and WebActivatorEx, and all the corresponding .dll files are ending up in your app's bin directory.

此外,您不需要(也不应该)在JavaScript包中包含JSXTransformer,因为ReactJS.NET会在服务器端完成所有JSX编译.

Also, you do not need to (and should not) include JSXTransformer in your JavaScript bundles, as ReactJS.NET does all the JSX compilation server-side.

这篇关于ReactJS.NET-捆绑包-TinyIoCResolutionException:无法解析类型:React.IReactEnvironment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:04