-
Notifications
You must be signed in to change notification settings - Fork 916
Description
Hi there,
Despite it working for a week or more beforehand, suddenly now getting these errors whenever I call a ReactJS.NET Html helper:
[TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment]
React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) +821
React.TinyIoC.TinyIoCContainer.Resolve() +46
React.ReactEnvironment.get_GetCurrentOrThrow() +66
[ReactNotInitialisedException: ReactJS.NET has not been initialised correctly. Please ensure you have called services.AddReact() and app.UseReact() in your Startup.cs file.]
React.ReactEnvironment.get_GetCurrentOrThrow() +158
React.Web.Mvc.<>c__DisplayClass2_0`1.<React>b__0(TextWriter writer) +359
React.Web.Mvc.ActionHtmlString.ToHtmlString() +201
System.Web.WebPages.WebPageBase.Write(Object value) +103
ASP._Page_Areas_Administration_Views_LoginPageStatusMessages_Index_cshtml.Execute() in C:\git\CompTracker.Web\src\CompTracker.Web\Areas\Administration\Views\LoginPageStatusMessages\Index.cshtml:31
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +88
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +775
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +775
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +973
System.Web.Mvc.<>c__DisplayClass22.<BeginExecuteCore>b__1e() +39
System.Web.Mvc.Async.AsyncResultWrapper.<.cctor>b__0(IAsyncResult asyncResult, Action action) +24
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +43
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +602
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +128
My application is an ASP.NET MVC 5 web app running in IIS 10.0.17763.1, and I have the following initialization code running at application start:
IReactSiteConfiguration config = ReactSiteConfiguration.Configuration;
config
.SetLoadReact(false)
.SetLoadBabel(false)
.SetReuseJavaScriptEngines(true);
#if DEBUG
const string reactLibraryType = "development";
const string otherType = "";
#else
const string reactLibraryType = "production.min";
const string otherType = ".min";
#endif
const string reactDirectory = "~/Scripts/ReactJS/";
string reactBundle = reactDirectory + $"ReactJS.bundled.{reactLibraryType}.js";
string reactServer = reactDirectory + $"Libraries/react-dom-server.browser.{reactLibraryType}.js";
string components = reactDirectory + $"ReactJS.server-side-components.bundled{otherType}.js";
void AddScripts(params string[] scripts)
{
foreach (string script in scripts)
{
config.AddScriptWithoutTransform(script);
}
}
AddScripts(
reactBundle,
reactServer,
components
);
JsEngineSwitcher.Instance.DefaultEngineName = V8JsEngine.EngineName;
JsEngineSwitcher.Instance.EngineFactories.AddV8();(The React bundle contains the React and ReactDOM libraries.)
I went around ReactJS.NET and attempted to render the components via ReactDOM.render, and they worked as expected, so it doesn't appear to be a problem with my bundles or scripts.
As per the JSEngineSwitcher misconceptions (#409) article, I also have the JSEngineSwitcher V8.Native x86 package installed, I confirmed that x64\ClearScriptV8-64.dll and x64\v8-x64.dll are being copied to my bin\ folder, and attempting to install the appropriate C++ redistributable gives me a message that I already have it installed. I've tried installing the x86 native package as well just in case, and no difference.
Here are the versions of relevant packages I have installed:
<package id="JavaScriptEngineSwitcher.ChakraCore" version="2.4.28" targetFramework="net471" />
<package id="JavaScriptEngineSwitcher.Core" version="2.4.10" targetFramework="net471" />
<package id="JavaScriptEngineSwitcher.Msie" version="2.4.19" targetFramework="net471" />
<package id="JavaScriptEngineSwitcher.V8" version="2.4.13" targetFramework="net471" />
<package id="JavaScriptEngineSwitcher.V8.Native.win-x64" version="2.4.16" targetFramework="net471" />
<package id="JavaScriptEngineSwitcher.Vroom" version="2.4.15" targetFramework="net471" />
<package id="React.Core" version="3.4.1" targetFramework="net471" />
<package id="React.Web" version="3.4.1" targetFramework="net471" />
<package id="React.Web.Mvc4" version="3.4.1" targetFramework="net471" />Any ideas?