Unable to resolve type: React.IReactEnvironment on certain PC
Opened this issue · 4 comments
Please verify these steps before filing an issue, and check them off as you go
- The relevant native JavascriptEngineSwitcher library packages are installed (such as
JavaScriptEngineSwitcher.V8.Native.win-x64) - The VC++ 2017 runtime is installed
- The value of
SetUseReactandSetUseBabelis correct inReactConfig.csorStartup.cs - I've looked at the sample projects in this repo to verify that my app is configured correctly
I'm using these library versions:
ReactJS.NET: 5.2.10JavaScriptEngineSwitcher: 3.5.5reactandreact-dom: 16.14.0webpack: (N/A if using bundled react) N/A - We are not using this, but not using the bundled version of reactnode: (N/A if using bundled react) N/A - We are not using this, but not using the bundled version of react
Runtime environment:
- OS: Windows 10 x64
- .NET Framework or .NET Core Version: .Net Framework 4.8
Steps to reproduce
- Launch our web app.
- Navigate to a page that renders a Razor view that calls Html.React()
- Observe the following exception.
Unable to resolve type: React.IReactEnvironment
[TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment]
React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) in D:\a\1\s\src\React.Core\TinyIoC\TinyIoC.cs:3825
React.TinyIoC.TinyIoCContainer.Resolve() in D:\a\1\s\src\React.Core\TinyIoC\TinyIoC.cs:1944
React.ReactEnvironment.get_GetCurrentOrThrow() in D:\a\1\s\src\React.Core\ReactEnvironment.cs:102
[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() in D:\a\1\s\src\React.Core\ReactEnvironment.cs:106
React.Web.Mvc.HtmlHelperExtensions.React(HtmlHelper htmlHelper, String componentName, T props, String htmlTag, String containerId, Boolean clientOnly, Boolean serverOnly, String containerClass, Action`3 exceptionHandler, IRenderFunctions renderFunctions) +517
ASP._Page_Areas_Administration_Views_LoginPageStatusMessages_Index_cshtml.Execute() in C:\Users\Zak (Work)\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) +384
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +97
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +829
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +829
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +35
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
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.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +49
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() +657
System.Web.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0() +46
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +155
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +140
We do not observe this issue on either our testing environment servers or another developer's PC. This leads me to thing something about my particular setup isn't correct. Most of the reading I've done where this error occurs seems to result from something being set up incorrectly in the code when configuring react, but since this issue is specific to my PC that seems unlikely.
Any input on this would be much appreciated.
Any chance we could get someone to look at this issue? It's been a few months, and it's a significant blocker in us being able to use ReactJS.NET in our project.
I should note that the project we're having this problem in is the same one as #640. However, I reinstalled Windows and everything else since and got it to work on my machine. However, Zak had to do the same thing and ran into the problems described in this issue.
Is this project still being maintained? We would really appreciate a response here.