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

Cannot load V8 interface assembly. Load failure information for ClearScriptV8-64.dll #79

Closed ArgonAlex closed 4 years ago

ArgonAlex commented 4 years ago

d:\git\mysite\bin\x64\ClearScriptV8-64.dll: Could not load file or assembly 'ClearScriptV8-64.dll' or one of its dependencies. The specified module could not be found.

I'm attempting to upgrade from JavaScriptEngineSwitcher 3.1.5 to 3.3.0 and seeing this exception. Visual C++ Redistributable 2019 is installed and I even tried upgrading it to the latest version.

JavaScriptEngineSwitcher.Core, JavaScriptEngineSwitcher.V8, JavaScriptEngineSwitcher.V8.Native.win-x64 are all on 3.3.0 and everything in the bin directory looks good. d:\git\mysite\bin\x64\ClearScriptV8-64.dll exists and it is version 6.0.0

This is happening on a dev environment with Visual Studio 2019 installed, and on a clean staging environment with just the essentials, including Visual C++ Redistributable 2019.

Environment Info: x64 web application project, targeting .NET 4.7.1 Paket package manager Windows Server 2019

Taritsyn commented 4 years ago

Hello, Alex!

What ASP.NET framework do you use?

ArgonAlex commented 4 years ago

It's an ASP.NET Web Application, targeting .NET Framework 4.7.1

Taritsyn commented 4 years ago

MVC or Web Forms?

ArgonAlex commented 4 years ago

Primarily Web Forms for pages, but also some MVC for API endpoints.

Taritsyn commented 4 years ago

I checked on MVC and I didn't have any problems.

The following assemblies must be located in the bin\x64\ directory:

ArgonAlex commented 4 years ago

Yup those are all there and are the correct versions. I've also gone as far as using Process Monitor to see that all of the DLLs under bin/x64 are in fact being read.

I just created a new Web Forms ASP.NET Web Application and it works for me too. There must be something specific about the way our particular application is configured, but I don't know why it worked for many previous versions of JSES/ClearScript and is only just failing on this one.

Other things I've tried:

Not sure where to go from here. I wish Microsoft would give a more useful reason for why it can't load the DLL other than FileNotFound.

ArgonAlex commented 4 years ago

Good(ish) news! I decided to copy over the web.config from the non-working application to the new one, and voila I saw the same exception. After doing a binary search of commenting out config sections, commenting out this made it so the DLL could be successfully loaded: <identity impersonate="true"/> So I think it must be something related to permissions.

In any case, this seems like a problem with ClearScript, not so much with JSES. Maybe I'll post an issue on the ClearScript repo.

Taritsyn commented 4 years ago

Hello, Alex!

In version 3.3.0 I changed the mechanism of assembly loading in the AssemblyResolver class. This mechanism now relies on the internal implementation of the ClearScript library.

ArgonAlex commented 4 years ago

Ah that would explain why I was running into the same problem with the Microsoft.ClearScript NuGet package, even the older versions of it.

Taritsyn commented 4 years ago

Microsoft.ClearScript NuGet package uses a different directory structure, so it was never compatible with the JavaScriptEngineSwitcher.V8 module.

ArgonAlex commented 4 years ago

I meant when I removed JSES from the project and just used ClearScript directly, I had the same issue with being unable to load ClearScriptV8-64.dll, so it certainly seems like an issue there.

Taritsyn commented 4 years ago

Most likely, these problems are somewhere in the V8Proxy class.

ArgonAlex commented 4 years ago

An update for anyone else who comes across this: our solution was to force the assembly to load during Application_Start instead of during the first request. Under that context it seemed to have the necessary permissions.

In other news, it looks like ClearScript 6.0.1, released today, fixes some possibly related permission issues when loading the assemblies. So that may also fix it.

Anyway, I'm going to close this issue since it's a ClearScript issue, and there is a workaround/it may be fixed.

Taritsyn commented 4 years ago

Hello, Alex!

In version 3.5.1 added support of Microsoft ClearScript.V8 version 6.0.1.