ClearScript.V8 works in UnitTest but does not in ASP.NET MVC Application

Sep 23, 2013 at 11:59 AM
Hey guys,
First of all: thanks for the brilliant work you guys have done so far!
Will try to keep it lean so that I don't compromise the tech info.

My solution is a .NET 4.5 one with some assemblies, including.
  • OOHMPRINT.Infra.V8 (Class Library)
  • OOHMPRINT.App (ASP.NET MVC 4 app)
  • OOHMPRINT.Tests (Class Library, with MsTest embeded)
I have ClearScript.v8 nuget package loaded in the OOHMPRINT.Infra.V8.
We also have created a unit test for our ExtractionProvider from this assembly in which I run javascript through V8.

1) In the unit test, it works perfecly
2) In the WebApplication it doesn't.

First, I was getting an error telling me that the ClearScriptV8-32 module was not found.

After going through discussions and other things, I found this, that helped me to figure out about the shadowCopy assemblies trick, which led me to a second problem.

The problem that I get in the Web Application is the following
Could not load file or assembly 'ClearScriptV8-64' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Some extra info:
  • Both my UnitTest lib and my WebApp are running in AnyCpu.
  • I have attempted to change it all to x86 and x64, and no difference
  • I have also attempted to deploy on WebDeveloper Server, IIS Experss and IIS
I need a hand in it.

Thanks in advance.

Cheers,
Hudson
Coordinator
Sep 23, 2013 at 1:16 PM
Edited Sep 23, 2013 at 3:55 PM
Hello, Hudson!

The ClearScript.V8 NuGet package doesn't quite work with ASP.NET projects. Please try the following:
  • In the project(s) where you added the NuGet package, delete the post-build steps that copy ClearScript's native assemblies to $(TargetDir).
  • Make sure that ClearScript's native assemblies (ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, and v8-x64.dll) do not appear in your web application's output directory ("bin" by default). For some reason ASP.NET just doesn't like mixed-mode assemblies in the output directory.
  • Add ClearScript's native assemblies to your web application as content files. You should be able to find them in $(SolutionDir)packages\ClearScript.V8.5.3.7.0\tools\native\[x86|amd64].
Please let us know if this works for you.
Thank you!
Sep 24, 2013 at 1:36 AM
This worked!
And you guys rock!!!!
Coordinator
Sep 24, 2013 at 4:10 AM
Glad to hear it! Thank you!