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

JavaScriptEngineSwitcher.V8 latest version uses the ClearScript dll whose publickey token is not matching the one that is in the manifest #29

Closed github-prometheus closed 7 years ago

github-prometheus commented 7 years ago

Hi Taritsyn,

I added the JavaScriptEngineSwitcher.V8 nuget package version 2.4.0 to my asp.net mvc4 application and made necessary changes in the Global.asax.cs file and also in the web.config but when I run my application, I am getting the error as

System.IO.FileLoadException: Could not load file or assembly 'ClearScript, Version=5.4.9.0, Culture=neutral, PublicKeyToken=935d0c957da47c73' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at JavaScriptEngineSwitcher.V8.V8JsEngine.LoadUndefinedValue()
   at JavaScriptEngineSwitcher.V8.V8JsEngine..cctor()

Here I noticed the thing that the public key token 935d0c957da47c73 is coressponds to the ClearScript version 5.4.7

If I install the JavaScriptEngineSwitcher.V8 nuget package version 2.1.0, the application runs fine since it finds the correct version of the ClearScript.

Can you please confirm if this is a potential bug that might have been caused while publishing nuget package? Please find the attached screenshots that corresponds to the public key token of the ClearScript.dll version 5.4.9 and 5.4.7 respectively.

Thanks, Pramod

clearscript

Taritsyn commented 7 years ago

Hello, Pramod!

Are you using the ClearScript.V8 package?

github-prometheus commented 7 years ago

yes

Taritsyn commented 7 years ago

You can not install the JavaScriptEngineSwitcher.V8 and ClearScript.V8 packages together. Both projects contain their own versions of assemblies, which signed by own keys. By the way, ClearScript.V8 package is unofficial. In general, Microsoft does not have an official NuGet package for the ClearScript library, and everyone builds the ClearScript on their own.

Uninstall the ClearScript.V8 package and read the “JS Engine Switcher: V8” section of documentation.

github-prometheus commented 7 years ago

Ok. Uninstalling the clearscript will add the required assemblies in the bin folder ? Currently I am adding those native dlls using a post build event.

Taritsyn commented 7 years ago

Uninstalling the clearscript will add the required assemblies in the bin folder ?

Have you read the “JS Engine Switcher: V8” section of documentation? Or at least the JavaScriptEngineSwitcher.V8 package description?

github-prometheus commented 7 years ago

Yes I installed those packages as well. Also I have installed the vc++ redist. 2015

Taritsyn commented 7 years ago

Currently I am adding those native dlls using a post build event.

You just need to install the JavaScriptEngineSwitcher.V8.Native.win-x86 and/or JavaScriptEngineSwitcher.V8.Native.win-x64 packages.

Taritsyn commented 7 years ago

Yes I installed those packages as well. Also I have installed the vc++ redist. 2015

Then should all work correctly. If it doesn't work, then clean your project from garbage: the ClearScript.V8 package artifacts and custom post build events.

github-prometheus commented 7 years ago

Hi Taritsyn,

Following your steps enabled the local application to run successfully but when deployed to the server, The folders X86 and x64 folders didnt get created in the websites bin folder but a ClearScript folder got generated in the in project folder and I am getting the same error.

Just to be clear, does the ClearScript.V8 folder gets created in the project folder ?

Thanks Pramod

Taritsyn commented 7 years ago

Since version 2.0 the ClearScript.V8 directory is not created. Assemblies are copied by using MSBuild scripts to x86 and x64 subdirectories of bin\[Debug|Release] directory (for web applications just bin directory).

github-prometheus commented 7 years ago

So Andrey please correct me if I am wrong : for web application the ClearScript.V8 directory does not get created and the dlls directly get copied to bin/x86 and bin/x64 respectively.

In my local I can observe the changes but in remote server its getting created. I am using bamboo to create the installer.

On Thu, May 11, 2017 at 11:02 PM, Andrey Taritsyn notifications@github.com wrote:

Since version 2.0 the ClearScript.V8 directory is not created. Assemblies are copied by using MSBuild scripts to x86 and x64 subdirectories of bin[Debug|Release] directory (for web applications just bin directory).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/29#issuecomment-300861289, or mute the thread https://github.com/notifications/unsubscribe-auth/AbS-x3nydMdAz_Wv9vHaU6THvN_h6wkTks5r40Y2gaJpZM4NXyZ3 .

Taritsyn commented 7 years ago

So Andrey please correct me if I am wrong : for web application the ClearScript.V8 directory does not get created and the dlls directly get copied to bin/x86 and bin/x64 respectively.

Yes, that's right.

In my local I can observe the changes but in remote server its getting created. I am using bamboo to create the installer.

In this matter I can not help you. Check your installer or deployment scripts.

github-prometheus commented 7 years ago

Thanks Andrey I will check that.

github-prometheus commented 7 years ago

I added those assemblies as link in root project directory

github-prometheus commented 7 years ago

Also Andrey, Can we use the latest version with BundleTransformer v1.8.32 ?

cause when i did I got the exception message like :

Method not found: 'JavaScriptEngineSwitcher.Core.JsEngineSwitcher JavaScriptEngineSwitcher.Core.JsEngineSwitcher.get_Current()'.
Taritsyn commented 7 years ago

Can we use the latest version with BundleTransformer v1.8.32 ?

It's too old version. Since Bundle Transformer version 1.9.122 supports the JavaScript Engine Switcher version 2.X. I recommend to read the “How to upgrade applications to version 2.X” section of the documentation and upgrade the Bundle Transformer to latest version.

And let's finish this discussion. After all, this is an open source projects, but not a paid support service.

github-prometheus commented 7 years ago

Ok.. Sure Andrey. Thanks a lot :)

fm-gawdeprasad commented 7 years ago

Hi Andrey ,

I read the article at link1. I also checked for msvcp140.dll. Then I added a nuget package for JavaScriptEngineSwitcher.V8 (2.4.2) and JavaScriptEngineSwitcher.V8.Native.win-x86 (2.4.2). Then I added following code

using Microsoft.ClearScript.V8;
public static void main(){
    var en = new V8ScriptEngine();
}

But I am getting exception as Could not load file or assembly 'ClearScriptV8-32.DLL' or one of its dependencies. The specified module could not be found.. I am clueless here. My project is in 4.5.1 framework. Any inputs as what I am missing?

I have uploaded the sample code at link2

Taritsyn commented 7 years ago

Hello, Prasad!

You incorrectly create an instance of JS engine. Forget about the V8ScriptEngine class from Microsoft.ClearScript.V8 namespace, you need to use the V8JsEngine class from JavaScriptEngineSwitcher.V8 namespace.

I recommend you to read the “Creating instances of JS engines” and “JS Engine Switcher: V8” sections of documentation.

fm-gawdeprasad commented 7 years ago

Hello Andrey,

I read the articles and I changed the code to what you have suggested but unfortunately I am getting the said error even before the execution hits the break point. The exception is being thrown by CLR on home page launch (which does not have engine creation code).

PS: I am using VS2015.

Taritsyn commented 7 years ago

In your project the ClearScriptV8-32.dll and v8-ia32.dll assemblies are located outside of the bin/x86 directory.

fm-gawdeprasad commented 7 years ago

Thanks a ton Taritsyn. I had copied them out earlier with the previous incorrect implementation. Now the issue is fixed