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
440 stars 49 forks source link

Issue running v1.3.3 and v2.4.13 side-by-side #51

Closed momadthenomad closed 6 years ago

momadthenomad commented 6 years ago

I have a web application with several child web applications.

All the web applications have v1.1.3 installed.

But if I update to the latest version on one of the child web applications, I get this error: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

It has to do with the native dlls and Visual C++ Redistributable for Visual Studio 2015.

Any help is appreciated.

Thanks

Taritsyn commented 6 years ago

Hello, Mohamed!

I recommend you to read “How to upgrade applications to version 2.X” section of the documentation and “Misconceptions about the JavaScript Engine Switcher version 2.X” discussion.

momadthenomad commented 6 years ago

Hello @Taritsyn,

I read all of that and it doesn't help. The problem is that I have nested web applications (parent and child). I am upgrading the child web application with the new version of JavaScriptEngineSwitcher. I installed the VC2015-redist. I got it working as a standalone web app.

Since the parent web app has the web.config lines for JsEngineSwitcher, I am thinking that might be the problem. But also, I ran into an issue where if I install VC2015-redist, the old version stops working (v1.1.3 of the jsEngineSwitcher). But if I also install VC2017-redist, it works again.

But regardless of that, it appears whichever you load first (the parent or child web apps), the other one will fail with this error:

A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

[FileLoadException: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +478
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +128
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +34
   Microsoft.ClearScript.V8.V8Proxy.LoadAssembly() +47
   Microsoft.ClearScript.V8.V8Proxy.GetAssembly() +34
   Microsoft.ClearScript.V8.V8Proxy.GetImplType(Type type) +33
   Microsoft.ClearScript.V8.V8Proxy.CreateImpl(Object[] args) +160
   Microsoft.ClearScript.V8.V8Runtime..ctor(String name, V8RuntimeConstraints constraints, V8RuntimeFlags flags, Int32 debugPort) +273
   Microsoft.ClearScript.V8.V8ScriptEngine..ctor(V8Runtime runtime, String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, Int32 debugPort) +183
   JavaScriptEngineSwitcher.V8.V8JsEngine..ctor(V8Settings settings) +174
Taritsyn commented 6 years ago

Upgrade both web applications to version 2.X.

Since the parent web app has the web.config lines for JsEngineSwitcher, I am thinking that might be the problem.

Clearly written in the documentation:

  1. After upgrade of old packages, you must remove the jsEngineSwitcher configuration section group and its declaration from the Web.config and App.config files:
momadthenomad commented 6 years ago

@Taritsyn, is that the only way?

It is not possible for me to update the parent yet, and in fact, our application is setup with one parent and over 20 children. I was hoping to update them one at a time instead of all in one fell swoop as I don't own all of the apps and have to coordinate the update with the teams that own them.

Taritsyn commented 6 years ago

[FileLoadException: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.]

Check a existance of the ClearScriptV8-64.dll assembly in the bin/x64 directory.

momadthenomad commented 6 years ago

Yep, it exists. Also the v8-x64.dll exists.

Taritsyn commented 6 years ago

Version 1.1.3 require the the Visual C++ Redistributable for Visual Studio 2012, but version 2.4.13 the Microsoft Visual C++ 2015 Redistributable.

Taritsyn commented 6 years ago

I can not advise to you anything, because I do not see the source code of your web applications. Try to reproduce these errors on the demo project, and then send me its source code.

momadthenomad commented 6 years ago

Thanks! It's possible I am having issues because both parent and child are on the same Application Pool in this case. That is not the case in production, so I will test that configuration and see if that resolves my issue.

Taritsyn commented 6 years ago

While I can give only one advice: in web applications, that use the older version, leave the JavaScriptEngineSwitcher.V8, but in web applications, that use the new version, install the JavaScriptEngineSwitcher.ChakraCore instead of the JavaScriptEngineSwitcher.V8. When you finish updating of all web applications, you can everywhere return the JavaScriptEngineSwitcher.V8.

momadthenomad commented 6 years ago

@Taritsyn - my problem is now resolved.

It was due to my test environment running all of the apps in the same App Pool.

I am interested in ChakraCore, are you recommending that I use ChakraCore instead of V8? I don't mind but would love to hear your rationale for ChakraCore.

Thanks

momadthenomad commented 6 years ago

@Taritsyn - also, it works with VC++ 2017 redist as well.

Taritsyn commented 6 years ago

I am interested in ChakraCore, are you recommending that I use ChakraCore instead of V8? I don't mind but would love to hear your rationale for ChakraCore.

At the moment, V8 and ChakraCore engines are very similar in their characteristics, so they can replace each other. The main advantage of the JavaScriptEngineSwitcher.ChakraCore module is cross-platform.