Taritsyn / JavaScriptEngineSwitcher

JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines. This library allows you to quickly and easily switch to using of another JavaScript engine.
Apache License 2.0
439 stars 49 forks source link

JavaScriptEngineSwitcher.Core.JsEngineNotFoundException #113

Closed yeshwanth-t closed 8 months ago

yeshwanth-t commented 8 months ago

Hi,

I have been using v3.1.0 for quite long time and this was working well. Now, I upgraded to v3.21.0 and getting the below error. JavaScriptEngineSwitcher.Core.JsEngineNotFoundException: Could not find a factory, that creates an instance of the JavaScript engine with name ChakraCoreJsEngine.

The below is the versions list that I got installed.

I tried to rollback to older version but still the error occurs. Is there anything that got changed? More detailed explanation in below link. https://sitecore.stackexchange.com/questions/36568/bundletransformer-assettranslationexception-could-not-find-factory

Taritsyn commented 8 months ago

Hello!

Try to re-read the “Registration of JS engines” section of documentation.

yeshwanth-t commented 8 months ago

Thanks @Taritsyn . All those registrations are already in place in my web application. Is there any breaking changes from 3.1.0 to 3.21.0?

Taritsyn commented 8 months ago

Is there any breaking changes from 3.1.0 to 3.21.0?

No.

It's possible that you need to read this.

Taritsyn commented 8 months ago

JavaScriptEngineSwitcher.Core.JsEngineNotFoundException: Could not find a factory, that creates an instance of the JavaScript engine with name ChakraCoreJsEngine.

This error message means that JS engine has not been registered. Check your the Global.asax.cs file there should be the following line of code:

JsEngineSwitcherConfig.Configure(JsEngineSwitcher.Current);
yeshwanth-t commented 8 months ago
JsEngineSwitcher

I do have the below code in my Global.asax.cs

public override void Application_Start(object sender, EventArgs e)
{ IdentityModelEventSource.ShowPII = true; JsEngineSwitcherConfig.Configure((JsEngineSwitcher)JsEngineSwitcher.Current); }

Taritsyn commented 8 months ago

JsEngineSwitcherConfig.Configure((JsEngineSwitcher)JsEngineSwitcher.Current);

Why are you doing a type conversion? It seems that you have incorrectly migrated from version 2.X to 3.X (see the “How to upgrade applications to version 3.X” section of documentation).

B-Ahdoot commented 8 months ago

I am working with @yeshwanth-t. We have 2 workstations already running using the typecasting above. Without the typecast, we receive this error: cannot convert from 'JavaScriptEngineSwitcher.Core.IJsEngineSwitcher' to 'JavaScriptEngineSwitcher.Core.JsEngineSwitcher'

Taritsyn commented 8 months ago

@B-Ahdoot, As far as I understand, you control contents of the App_Start/JsEngineSwitcherConfig.cs file yourself. Just change argument type of the Configure method to the IJsEngineSwitcher and you won't need type conversion.

To avoid the error described by @yeshwanth-t, you need to ensure that the JsEngineSwitcherConfig.Configure method is called before calling the BundleConfig.RegisterBundles method. As an example, you can look at the BundleTransformer.Sample.AspNet45.Mvc4 demo project (pay special attention to the App_Start/JsEngineSwitcherConfig.cs and Global.asax.cs files).

yeshwanth-t commented 8 months ago

@Taritsyn Thank you. The above two suggestions worked great and I am able to resolve those errors. Once again thank you for actively supporting us!!