Skip to content

Unable to resolve type: React.IReactEnvironment on certain PC #1236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
zturchan opened this issue Jan 8, 2021 · 4 comments
Open
4 tasks done

Unable to resolve type: React.IReactEnvironment on certain PC #1236

zturchan opened this issue Jan 8, 2021 · 4 comments

Comments

@zturchan
Copy link

zturchan commented Jan 8, 2021

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 SetUseReact and SetUseBabel is correct in ReactConfig.cs or Startup.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.10
  • JavaScriptEngineSwitcher: 3.5.5
  • react and react-dom: 16.14.0
  • webpack: (N/A if using bundled react) N/A - We are not using this, but not using the bundled version of react
  • node: (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


  1. Launch our web app.
  2. Navigate to a page that renders a Razor view that calls Html.React()
  3. 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.

@adamjford
Copy link

adamjford commented Apr 1, 2021

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.

@adamjford
Copy link

Is this project still being maintained? We would really appreciate a response here.

@dustinsoftware
Copy link
Member

dustinsoftware commented Apr 27, 2021 via email

@adamjford
Copy link

adamjford commented Apr 28, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants