reactjs / React.NET

.NET library for JSX compilation and server-side rendering of React components
https://reactjs.net/
MIT License
2.3k stars 933 forks source link

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

Open zturchan opened 3 years ago

zturchan commented 3 years ago

Please verify these steps before filing an issue, and check them off as you go

I'm using these library versions:

Runtime environment:

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 commented 3 years ago

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 commented 3 years ago

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

dustinsoftware commented 3 years ago

Nope, sorry. I do this in my free time (unpaid) and haven’t had the motivation to come back to it in a while. :)

If you do find a fix let me know and I’ll see if we can merge something in…

On Tue, Apr 27, 2021 at 18:14, Adam Ford @.***> wrote:

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/reactjs/React.NET/issues/1236#issuecomment-827970861, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHGCFVAC5Q5LKWVCL52CZLTK4ZNJANCNFSM4V24KRPA .

adamjford commented 3 years ago

Understandable. Thank you for the response.

On Tue, Apr 27, 2021 at 5:33 PM Masters @.***> wrote:

Nope, sorry. I do this in my free time (unpaid) and haven’t had the motivation to come back to it in a while. :)

If you do find a fix let me know and I’ll see if we can merge something in…

On Tue, Apr 27, 2021 at 18:14, Adam Ford @.***> wrote:

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/reactjs/React.NET/issues/1236#issuecomment-827970861 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAHGCFVAC5Q5LKWVCL52CZLTK4ZNJANCNFSM4V24KRPA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/reactjs/React.NET/issues/1236#issuecomment-828023324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABKV3NLVAERDOOLM4QFFADTK5CVZANCNFSM4V24KRPA .