5

I am getting the following error:

 Unable to resolve type: React.ReactEnvironment

InnerException:

Unable to resolve type: React.JavaScriptEngineFactory

InnerException:

Object doesn't support this property or method

this is Application_Start

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

this is BundleConfig.RegisterBundles

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

And this is Home/Index View

@{
    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>

the error occurs at this line

 @Scripts.Render("~/bundles")

Update1 When I tried to access /Scripts/HelloWorld.jsx directly in the browser I got this server error message:

MsieJavaScriptEngine.JsRuntimeException: Object doesn't support this property or method
Anas Alweish
  • 2,818
  • 4
  • 30
  • 44
Diaa Eddin
  • 389
  • 3
  • 13
  • try my updated answer – cpr43 Mar 18 '17 at 18:38
  • it did not work . – Diaa Eddin Mar 18 '17 at 18:55
  • find my answer here. https://stackoverflow.com/questions/28819464/reactjs-net-bundles-tinyiocresolutionexception-unable-to-resolve-type-reac/54171095#54171095 – Emil Jan 14 '19 at 13:34
  • Possible duplicate of [ReactJS.NET - Bundles - TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment](https://stackoverflow.com/questions/28819464/reactjs-net-bundles-tinyiocresolutionexception-unable-to-resolve-type-reac) – Emil Jan 14 '19 at 13:34

1 Answers1

1

We shoul create a static ReactConfig class and configure ReactSiteConfiguration with all the .jsx file present.

We should add our .jsx files to the scripts as follows

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

In Application_start call

RouteConfig.Configure();
cpr43
  • 2,942
  • 1
  • 18
  • 18