Skip to content

Unable to resolve type: React.ReactEnvironmentUnable to resolve type #410

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

Closed
mattgross76 opened this issue May 18, 2017 · 7 comments
Closed

Comments

@mattgross76
Copy link

Hello, I am able to reference a .jsx file from a page when running in debug mode on my local machine. If, however, I switch to IIS Express in debug mode, I begin to notice 500 errors when inspecting the generated page.

This problem also occurs when I perform "Start without debugging."

Lastly, when deploying to Windows Azure via automated VSTS builds, I also receive the 500 errors when inspecting the page where my .jsx component should be. I am able to obtain the following details from Azure application insights:

ERROR:
Unable to resolve type: React.ReactEnvironmentUnable to resolve type: React.JavaScriptEngineFactoryNo usable JavaScript engine was found. Please install a JavaScript engine such as React.JavaScriptEngine.ClearScriptV8 (on Windows) or React.JavaScriptEngine.VroomJs (on Linux and Mac OS X). Refer to the ReactJS.NET documentation for more details.

FAILED METHOD: React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType

I am using Visual Studio 2017 to build a MVC web application. I am using .NET Core version 1.1.

Any thoughts on why I am seeing different behaviors? Suggestions for making this work more consistently?

@mattgross76
Copy link
Author

Well, I was able to solve the local issue by adding a bit to my project file regarding which javascript engine to use based upon .net framework.

NOTE, I am still receiving the same error once deployed to Azure. Is there something special we need to do to make the solution work for .NET Core applications in Azure?

@Taritsyn
Copy link
Contributor

@mattgross76
Copy link
Author

@Taritsyn Thank you for the article and for the many nuget packages you have developed. I read it and have tried a few things, but still have the issue in Azure running a .NET Core 1.1 application. I am going to try to use Chakra instead of V8 to see if that makes a difference.

Do you have a recommendation regarding which engine to use with .NET Core 1.1 and Windows Azure? I'm having trouble finding documentation on that particular use case.

Thanks!
Matt

@Taritsyn
Copy link
Contributor

.NET Core is supported by four JS engines: JavaScriptEngineSwitcher.ChakraCore, JavaScriptEngineSwitcher.Msie (only works in JsRT modes), JavaScriptEngineSwitcher.Jint and JavaScriptEngineSwitcher.Vroom. But the JavaScriptEngineSwitcher.ChakraCore is the best choice at the moment.

I also recommend you to read this comment.

@Taritsyn
Copy link
Contributor

And read about registration of JS engines in ASP.NET Core 1.X.

@mattgross76
Copy link
Author

@Taritsyn Thank you so much! I think it is fixed now. My small experiment is at least now working within Azure. That second link regarding the "registration of JS engines in ASP.NET Core 1.X" was the key!

I added the following code to the Startup class, and it works now:
services.AddJsEngineSwitcher(options => options.DefaultEngineName = ChakraCoreJsEngine.EngineName ) .AddChakraCore()

For now, I am holding off on the other options.

Thanks again. I will close the issue.

@JoshuaKGoldberg
Copy link
Contributor

@mattgross76 what was the bit you added to your project file?

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