Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 opened this issue May 11, 2017 · 22 comments

Comments

@github-prometheus
Copy link

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
Copy link
Owner

Hello, Pramod!

Are you using the ClearScript.V8 package?

@github-prometheus
Copy link
Author

yes

@Taritsyn
Copy link
Owner

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
Copy link
Author

github-prometheus commented May 11, 2017

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
Copy link
Owner

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
Copy link
Author

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

@Taritsyn
Copy link
Owner

Taritsyn commented May 11, 2017

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

github-prometheus commented May 11, 2017 via email

@Taritsyn
Copy link
Owner

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
Copy link
Author

Thanks Andrey I will check that.

@github-prometheus
Copy link
Author

I added those assemblies as link in root project directory

@github-prometheus
Copy link
Author

github-prometheus commented May 12, 2017

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
Copy link
Owner

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
Copy link
Author

Ok.. Sure Andrey. Thanks a lot :)

@fm-gawdeprasad
Copy link

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
Copy link
Owner

Taritsyn commented Jun 5, 2017

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
Copy link

fm-gawdeprasad commented Jun 5, 2017

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
Copy link
Owner

Taritsyn commented Jun 5, 2017

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

@fm-gawdeprasad
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants