如何解决无法解析类型:React.ReactEnvironment异常

问题描述:

我收到以下错误:如何解决无法解析类型:React.ReactEnvironment异常

Unable to resolve type: React.ReactEnvironment 

的InnerException:

Unable to resolve type: React.JavaScriptEngineFactory 

的InnerException:

Object doesn't support this property or method 

这是的Application_Start

AreaRegistration.RegisterAllAreas(); 
    RouteConfig.RegisterRoutes(RouteTable.Routes); 
    BundleConfig.RegisterBundles(BundleTable.Bundles); 

这是BundleConfig.RegisterBundles

bundles.Add(new BabelBundle("~/bundles").Include("~/Scripts/HelloWorld.jsx")); 

这是首页/索引视图

@{ 
    ViewBag.Title = "Index"; 
} 

    <script src="~/Scripts/react/react.min.js"></script> 
    <script src="~/Scripts/react/react-dom.min.js"></script> 

@Scripts.Render("~/bundles") 
<div id="content"></div> 

在该行

@Scripts.Render("~/bundles") 

UPDATE1 当我试图出现错误直接在t中访问/Scripts/HelloWorld.jsx他的浏览器我得到这个服务器错误消息:

MsieJavaScriptEngine.JsRuntimeException: Object doesn't support this property or method 
+0

尽我更新的答案 – CPR43

+0

没有奏效。 –

我们建议立即进行删除创建一个静态ReactConfig类,并与所有.jsx文件目前配置ReactSiteConfiguration。

我们要我们的.jsx文件添加到脚本如下

public static class ReactConfig 
    { 
     public static void Configure() 
     { 
      ReactSiteConfiguration.Configuration 
      .AddScript("~/Scripts/HelloWorld.jsx"); 
     } 
    } 

在的Application_Start通话

RouteConfig.Configure(); 
+0

我添加了'ReactConfig'类,然后我在'Application_Start()'中调用了'RouteConfig.Configure()',但是错误仍然存​​在 –

+0

尝试在下面的视图中调用@ Html.ReactInitJavaScript()@ script.Render – CPR43