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

Trying to Run this in the GAC #73

Closed trevski closed 5 years ago

trevski commented 5 years ago

I am trying to update to run V8 instead of MSIE. We have an installer which allows all sites on a server to use the same version of bundleTransformer across 100's of websites loading the dlls from the GAC rather than local copies.

The trouble is that when I install the V8 engine, it cannot find the references in the x64 directory, I have tried copying these to the GAC folder and no luck.

Any Ideas

Taritsyn commented 5 years ago

Hello, Trevor!

Which assemblies did you try to copy to the GAC?

Taritsyn commented 5 years ago

Try copying the following assemblies to the GAC: JavaScriptEngineSwitcher.V8.dll, ClearScript.dll and ClearScriptV8-64.dll. And then copy the v8-base-x64.dll and v8-x64.dll assemblies into the C:\Windows\System32 directory. Also don't forget to install the Microsoft Visual C++ Redistributable for Visual Studio 2017.

trevski commented 5 years ago

Copying v8-base-x64.dll and v8-x64.dll into system32 did not seem to work. However copying then into C:\Windows\Microsoft.NET\assembly\GAC_MSIL\ClearScript\v4.0_5.5.6.0__935d0c957da47c73 did work for me. I just need to figure out how to get my installer to copy the files here... Thanks

Taritsyn commented 5 years ago

I created a corresponding issue #117 “How do I deploy a 64-bit ClearScriptV8 assemblies globally (at the machine level)?” in the ClearScript's repository.

Taritsyn commented 5 years ago

Try renaming the ClearScriptV8-64.dll assembly to the ClearScriptV8.dll.

Taritsyn commented 5 years ago

Just want to warn:

  1. ClearScript's assemblies from my packages (JavaScriptEngineSwitcher.V8, JavaScriptEngineSwitcher.V8.Native.win-x86 and JavaScriptEngineSwitcher.V8.Native.win-x64) are different from the assemblies of the official package, i.e. they have other strong names.
  2. Dynamic loading of native assemblies is also different from the official one (see the AssemblyResolver.cs file).
Taritsyn commented 5 years ago

If with the ClearScriptV8 library doesn't work out, then I recommend you to switch to the JavaScriptEngineSwitcher.ChakraCore module.

In this case, you must perform the following steps:

  1. Install the Microsoft Visual C++ Redistributable for Visual Studio 2017.
  2. Register the JavaScriptEngineSwitcher.ChakraCore.dll assembly from the JavaScriptEngineSwitcher.ChakraCore package in the GAC.
  3. Copy the ChakraCore.dll assembly from the JavaScriptEngineSwitcher.ChakraCore.Native.win-x64 package to the C:\Windows\System32 directory.
Taritsyn commented 5 years ago

Hello, Trevor!

Authors of the ClearScript answered me. While I recommend switching to the JavaScriptEngineSwitcher.ChakraCore module.

Taritsyn commented 5 years ago

Hello, Trevor!

Install a latest versions of packages:

Install-Package JavaScriptEngineSwitcher.V8 -Version 3.1.6
Install-Package JavaScriptEngineSwitcher.V8.Native.win-x86 -Version 3.1.5
Install-Package JavaScriptEngineSwitcher.V8.Native.win-x64 -Version 3.1.5

Also don't forget to install the Microsoft Visual C++ Redistributable for Visual Studio 2017.

Install into GAC the following assemblies: AdvancedStringBuilder.dll, JavaScriptEngineSwitcher.Core.dll, JavaScriptEngineSwitcher.V8.dll, ClearScript.dll, ClearScriptV8-32.dll and ClearScriptV8-64.dll.

And then copy to the C:\Windows\System32 directory (admin rights required) the native assemblies: v8-libcpp-ia32.dll, v8-base-ia32.dll, v8-ia32.dll, v8-libcpp-x64.dll, v8-base-x64.dll and v8-x64.dll.

To deploy the above assemblies I used the following commands running in the Developer Command Prompt for VS 2017 with administrator rights:

cd YOUR_APP_BIN_DIRECTORY

gacutil -i AdvancedStringBuilder.dll
gacutil -i JavaScriptEngineSwitcher.Core.dll
gacutil -i JavaScriptEngineSwitcher.V8.dll
gacutil -i ClearScript.dll
gacutil -i ClearScriptV8-32.dll
gacutil -i ClearScriptV8-64.dll

copy v8-libcpp-ia32.dll "%WINDIR%\system32\*.*"
copy v8-base-ia32.dll "%WINDIR%\system32\*.*"
copy v8-ia32.dll "%WINDIR%\system32\*.*"
copy v8-libcpp-x64.dll "%WINDIR%\system32\*.*"
copy v8-base-x64.dll "%WINDIR%\system32\*.*"
copy v8-x64.dll "%WINDIR%\system32\*.*"

It all worked on my computer.