React.NET icon indicating copy to clipboard operation
React.NET copied to clipboard

React.NET is broken in Visual Studio 2017 RC and .NET Core 1.1

Open olivierr91 opened this issue 9 years ago • 12 comments

As seen here: https://reactjs.net/getting-started/aspnetcore.html and here: https://github.com/reactjs/React.NET/issues/361

React.NET is broken in Visual Studio 2017 and .NET Core 1.1. Navigating to a JSX file fails with a "React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment" error message.

The issue has been reported by different users, yet we have not heard anything from the React.NET developpers for a while about it. Needless to say that this is a very serious problem and it should be top priority to fix because there is currently no acceptable workaround. May any developper officially acknowledge the issue? Is there an ETA for the fix?

Thank you very much

olivierr91 avatar Feb 07 '17 17:02 olivierr91

A while ago I wrote a diff that fixed React.NET in VS2017 for me, #354.

I believe it's still only available in the development version, and no-one has confirmed (or refuted!) for me yet that the fix is working for anyone other than myself.

Quoting @Daniel15

If you want to try the development version, you can use the NuGet package server on our AppVeyor build (https://ci.appveyor.com/nuget/reactjs.net/). Instructions are available at https://reactjs.net/getting-started/download.html#development-builds

If you have the option to try the dev build @orobert91, it's worth a shot, not least because I'd like to know if it actually works!

DaveKP avatar Feb 07 '17 18:02 DaveKP

Yeah, please try the dev version. Visual Studio 2017 is not RTM yet so I still haven't fully tested it. I might set up a VM and test it out.

Daniel15 avatar Feb 07 '17 18:02 Daniel15

Excellent! I will try it and give you feedback

olivierr91 avatar Feb 07 '17 19:02 olivierr91

I have tested the latest development build. Instead of React.TinyIoC.TinyIoCResolutionException I get the following exception: The type initializer for 'VroomJs.JsEngine' threw an exception. ---> System.TypeInitializationException: The type initializer for 'VroomJs.JsEngine' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'VroomJsNative': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at VroomJs.JsEngine.js_set_object_marshal_type(JsObjectMarshalType objectMarshalType) at VroomJs.JsEngine..cctor() --- End of inner exception stack trace --- at VroomJs.JsEngine..ctor(Int32 maxYoungSpace, Int32 maxOldSpace) at React.VroomJsEngine.<>c.<.cctor>b__23_0() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at React.VroomJsEngine..ctor() --- End of inner exception stack trace --- at React.VroomJsEngine..ctor() at React.VroomJsEngine.Factory.CreateEngine() at React.JavaScriptEngineFactory.GetFactory(JsEngineSwitcher jsEngineSwitcher, Boolean allowMsie)

olivierr91 avatar Feb 08 '17 16:02 olivierr91

I solved the issue by installing the JavaScriptEngineSwitcher.ChakraCore and JavaScriptEngineSwitcher.ChakraCore.Native.<your_OS> NuGet packages and manually specifying the JS engine.

Added: engineSwitcher.DefaultEngineName = ChakraCoreJsEngine.EngineName; engineSwitcher.EngineFactories.AddChakraCore(); Before app.UseReact(config => { });

Now I got a fully working ReactJS.NET under Visual Studio 2017 RC.

olivierr91 avatar Feb 10 '17 04:02 olivierr91

VroomJs is only really for Mono (Linux and Mac OS X), it's better to use ClearScript V8 on Windows.

Daniel15 avatar Feb 10 '17 04:02 Daniel15

V8 is not compatible with .NET Core. Jurassic is not compatible with .NET Core. Jint is slow Unless I am mistaken, the only decent option left is ChakraCore

olivierr91 avatar Feb 10 '17 04:02 olivierr91

Using the dev branch of ReactJS.NET with ChakraCore is the only way I've managed to get server-side rendering working in ASP .NET Core as well.

wilka avatar Feb 11 '17 16:02 wilka

I installed VS2017 RC today to test this out, but I can't even get a basic project working out-of-the-box. I created a new .NET Core 1.0 site, and when I run it using IIS Express I just get the "Chrome script debugging in Visual Studio is enabled" page followed by a blank page 😕

Daniel15 avatar Feb 13 '17 02:02 Daniel15

Also I can't open the ReactJS.NET project with VS2017 RC as I get these errors when it tries to convert the xproj files:

React.AspNet\React.AspNet.xproj: Could not read post-migration report at 'C:\Users\Daniel\AppData\Local\Temp\d5jrt05h.tva'.

React.AspNet\React.AspNet.xproj: Failed to migrate XProj project React.AspNet. 'dotnet migrate --skip-backup -s -x "C:\src\React.NET\src\React.AspNet\React.AspNet.xproj" "C:\src\React.NET\src\React.AspNet" -r "C:\Users\Daniel\AppData\Local\Temp\d5jrt05h.tva" --format-report-file-json' exited with error code 1.

React.AspNet\React.AspNet.xproj: No executable found matching command "dotnet-migrate"

Daniel15 avatar Feb 13 '17 02:02 Daniel15

.NET Core 1.0 is fairly new technology. Try updating your .NET Core packages to 1.1 using NuGet and update the SDK using https://www.microsoft.com/net/download/core#/current -> Current

olivierr91 avatar Feb 13 '17 04:02 olivierr91

I pushed out #354 as ReactJS.NET 3.0.1, which seems to fix this. After messing with VS2017 so it worked properly, I managed to create a new .NET Core 1.1 site and a local build of ReactJS.NET worked out-of-the-box after following the installation instructions at https://reactjs.net/getting-started/aspnetcore.html. Looks like it uses ChakraCore on .NET Core, which is fine.

Let me know if you still encounter issues!

Daniel15 avatar Feb 13 '17 05:02 Daniel15