6

I want to run a simple clearscript program. For this i created a new ConsoleProject and added the reference via nuget.

When creating the Engine (first line of code)

  using (var engine = new V8ScriptEngine()) 

i get

System.TypeLoadException was unhandled _HResult=-2146233054
_message=Cannot load V8 interface assembly; verify that the following files are installed with your application: ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, v8-x64.dll

I Only found the dlls: v8-ia32.dll, v8-x64.dll but not any ClearscriptV8-*.dll

I copied them to the compile output but that didn't change any when running the console.exe

I also downloaded the Package from Github and there is neither such a dll included. I only have a ClearScript.dll.

Running the included Console Project throws same error.

Where do I get those dlls from ? What am I missing ?

My output folder of the project looks like this; enter image description here

I also ran the update V8 command. It succeded but nothing changed enter image description here

Then I also installed the C++ Redistribueable like descriped here: Clearscript files cannot be found on host

Community
  • 1
  • 1
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143

5 Answers5

3

It's looking for the V8 32Bit version so make sure install this nuget package JavaScriptEngineSwitcher.V8.Native.win-x86. I was pulling my hair trying to figure out but this one definitely solved the issue for me.

PinoyDev
  • 949
  • 1
  • 10
  • 21
1

Solution is to use the installer

Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
  • After spending a beautiful day trying to figure it out... after I did my Windows 10 Creators update, which messed up the registry entries and GAC, this was the only solution (for me to be able to build the project). "Luckily" meltdown in runtime. Seems that the only fix for this is to fix GAC dlls, this will be my next step, but thanks for this. – Vedran Mandić Jul 11 '17 at 15:54
1

As suggested, the installer is one way to help resolve the situation.

Since there now exist a full Nuget Package, I will recommend to use that instead. It definitely made the whole install task so much easier.

Install-Package ClearScript.V8 

https://www.nuget.org/packages/ClearScript.V8/

Christopher Bonitz
  • 828
  • 1
  • 10
  • 22
0

I found that the Nuget installer fails if you are applying it to a web-site (i.e. no project file). This is because the script in install.ps1 attempts to append the script in PostBuildCmd.ps1 to a non-existent post-build-command. (The installer declares success, but it's not to be trusted!)

The post-build-command in question simply copies everything from both folders in ..\packages\ClearScript.V8.5.4.7\tools\native, into the bin folder of the application. However, if you just do that manually, then you get another problem mentioned in: Clearscript files cannot be found on host (i.e. preemptive pre-loading of DLLs). You'll need to add the

<remove ...

lines (defined in the item at that link) to web.config as well as performing the manual copy.

Community
  • 1
  • 1
0

On macOS with .NET 5.0, I could not find an Install-Package command, and the following command did not solve the problem:

dotnet add myproject.csproj package Microsoft.ClearScript.V8

Instead, I had to explicitly add Microsoft.ClearScript.V8.Native.osx-x64 to the project. Presumably, a separate Microsoft.ClearScript.V8.Native.* package would have to be added for each architecture where the project will be used.

At least, it seems that adding "foreign" packages does not cause any warnings or errors. There will be unnecessary package downloads under each architecture if several architectures are added, but perhaps that is the only reliable solution.

Otto G
  • 670
  • 7
  • 14