Clearscript files cannot be found on host
Asked Answered
B

7

22

Like a lot of others I'm receiving the following error when deploying my ASP.Net MVC application:

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

Clearscript was installed as part of an effort to transform less files on the fly for page requests.

I have tested my application locally in ISS Express and ISS without a hitch.

As suggested here http://clearscript3.rssing.com/chan-14849437/all_p12.html I've also included the missing code libraries as resources to my project.

ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, v8-x64.dll are all included in a folder ClearScript.V8 in the bin folder. Removing this folder does not resolve the issue.

At my wits end. Any help is appreciated.

Bumgardner answered 25/4, 2014 at 19:55 Comment(6)
Might be worth using the NuGet packages instead: nuget.org/packages/ClearScript.V8Perished
thank you for the suggestion but it made no difference. I made the suggested changes to the project - removing the build steps created by the package and adding the binaries to the content folder - without any luck. Instead a different error cropped up saying it was loading assemblies for the wrong platform (mismatch).Bumgardner
Make sure those DLLs are not anywhere in your bin directory. Put them in your app's root directory and set them to "Do not copy". If you've done that and your app works on your dev PC but fails when deployed, the problem could be permissions; check the identity of the deployment app pool.Shellback
Thanks for the suggestion but even though all works fine locally when deployed the issues arise. I am unable to check the identity as the target host is a shared one of the cheap variety. I've resorted to transforming the less files locally before uploading and removing all references to bundletransformer/clearscript.Bumgardner
i'm having the same issue after using web deploy on a site. using the v8 engine for .less compilation. it seems to be looking in the wrong folder: not looking in /bin/ClearScript.V8/Miscarry
I had the same issue as @Brad, in the end I used the package from NuGet + modified the post-build to put the files in the ClearScript.V8 folder (happens only with web application). Now it works like a charm. For console App the NuGet package works well.Dulcine
O
3

This was seconds time starting some project with clearscript v8, and good I remembered what was the issue first time. Loading Native Lib v8.

You would think somewhere in GETTING STARTED or similar topic, devs from ClearScript should have mentioned that you need to have V8 native lib located in subfolders 'ia32' or 'x64' (Platform x86 or Platform x64 respectfully). Create above subfolders. and place native v8 libs there (32bit into 'ia32', 64bit in 'x64').

I guess they forgot to write down that thought. just as reminder... source code taken from loader that helped me last time track the issue...

private static IntPtr LoadNativeLibrary()
{
    var suffix = Environment.Is64BitProcess ? "x64" : "ia32";
    var fileName = "v8-" + suffix + ".dll";
    var messageBuilder = new StringBuilder();

    var paths = GetDirPaths().Select(dirPath => Path.Combine(dirPath, deploymentDirName, fileName)).Distinct();
    foreach (var path in paths)
    {
        var hLibrary = NativeMethods.LoadLibraryW(path);
        if (hLibrary != IntPtr.Zero)
        {
            return hLibrary;
        }

        var exception = new Win32Exception();
        messageBuilder.AppendInvariant("\n{0}: {1}", path, MiscHelpers.EnsureNonBlank(exception.Message, "Unknown error"));
    }

    var message = MiscHelpers.FormatInvariant("Cannot load V8 interface assembly. Load failure information for {0}:{1}", fileName, messageBuilder);
    throw new TypeLoadException(message);
}

Oddly enough, this loader should have thrown more meaningful message in debug environment, but it didn't. Instead we have : FileNotFoundException with message "Could not load file or assembly 'ClearScriptV8' or one of its dependencies. The system cannot find the file specified.". Guess there in code elsewhere is another similar loader that actually doesn't use LoadLibrary but falls back to .Net default loader, giving meaningless Exception.

hope this helps others solve similar issues.

Odontoid answered 1/6, 2018 at 20:2 Comment(0)
C
25

the cause is that asp.net load instantly all libraries in /bin directory. I added the following rule to ignore Clearscript assemblies, and it worked

<configuration>
    <system.diagnostics>
        <trace autoflush="true" />
    </system.diagnostics>
    <system.web>
        <compilation>
            <assemblies>

                <remove assembly="ClearScriptV8-64" />
                <remove assembly="ClearScriptV8-32" />
               ....
            </assemblies>
        </compilation>

...

Cheerio answered 28/10, 2015 at 12:32 Comment(2)
How does this work? File not found, so we 'remove' them? Scratches head.Modestomodesty
This is great but can someone please explain how it works!Inveigh
S
16

To be clear this exception is not always caused by a missing ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll or v8-x64.dll. Oftentimes the issue is that a dll referenced by one of the aforementioned dlls cannot be found. In cases where the appropriate dlls are on the server installing the appropriate Visual C++ Redistributable will usually solve this transitive dependency issue.

According to the project's discussion forum ClearScript no longer supports Visual Studio 2012. Meaning the version of the Visual C++ Redistributable that needs to be installed on your server is dependent on the version of ClearScript your project is utilizing:

Sada answered 7/4, 2015 at 21:46 Comment(0)
B
10

Might be a bit late but this may help others coming to this post.

This is a common error when you don't have the Visual C++ Redistributable for Visual Studio 2012 or above installed on the hosting server

http://www.microsoft.com/en-gb/download/details.aspx?id=30679

Bidget answered 3/7, 2014 at 7:18 Comment(1)
+1; the crucial point here is the same as this answer in that "the specified module could not be found" doesn't actually mean "this DLL could not be found" but actually "a dependency of this DLL could not be found". (In both cases, it's the VC++ 2012 runtime, but that's a coincidence).Haemostasis
M
9

If you're deploying on Windows Server 2012 with IIS role, there are two things you should do to get ClearScriptV8 running:

  1. As @no1sprite pointed out:

you have to install on the hosting server the Visual C++ Redistributable for Visual Studio 2012 or above: http://www.microsoft.com/en-gb/download/details.aspx?id=30679

  1. Make sure you place ClearScript.dll in website's bin\ folder, and ClearScriptV8-64.dll and v8-x64.dll into bin\ClearScript.V8.

Optional, for 32-bit applications/platforms:

  1. If you use 32-bit platform, place ClearScriptV8-32.dll and v8-ia32.dll in website's bin\ClearScript.V8\ folder. Also, In IIS Manager, right-click on site's Application pool and select "Advanced settings...". Set property "Enable 32-bit applications" to true.
Mckeever answered 5/3, 2015 at 14:38 Comment(2)
awesome, saved my life. In my case the ClearScript.V8 folder was in my project but all the dlls inside needed to be marked "Copy always" or "Copy if newer" in the file properties for them to deploy correctly.Qualmish
@Qualmish In our case we had to disable (set to false) Enable 32-bit applications under the apps pools Advanced Settings. Thank you for the comment as it sent me down the right path and wanted to post this here in case it might help others.Sada
O
3

This was seconds time starting some project with clearscript v8, and good I remembered what was the issue first time. Loading Native Lib v8.

You would think somewhere in GETTING STARTED or similar topic, devs from ClearScript should have mentioned that you need to have V8 native lib located in subfolders 'ia32' or 'x64' (Platform x86 or Platform x64 respectfully). Create above subfolders. and place native v8 libs there (32bit into 'ia32', 64bit in 'x64').

I guess they forgot to write down that thought. just as reminder... source code taken from loader that helped me last time track the issue...

private static IntPtr LoadNativeLibrary()
{
    var suffix = Environment.Is64BitProcess ? "x64" : "ia32";
    var fileName = "v8-" + suffix + ".dll";
    var messageBuilder = new StringBuilder();

    var paths = GetDirPaths().Select(dirPath => Path.Combine(dirPath, deploymentDirName, fileName)).Distinct();
    foreach (var path in paths)
    {
        var hLibrary = NativeMethods.LoadLibraryW(path);
        if (hLibrary != IntPtr.Zero)
        {
            return hLibrary;
        }

        var exception = new Win32Exception();
        messageBuilder.AppendInvariant("\n{0}: {1}", path, MiscHelpers.EnsureNonBlank(exception.Message, "Unknown error"));
    }

    var message = MiscHelpers.FormatInvariant("Cannot load V8 interface assembly. Load failure information for {0}:{1}", fileName, messageBuilder);
    throw new TypeLoadException(message);
}

Oddly enough, this loader should have thrown more meaningful message in debug environment, but it didn't. Instead we have : FileNotFoundException with message "Could not load file or assembly 'ClearScriptV8' or one of its dependencies. The system cannot find the file specified.". Guess there in code elsewhere is another similar loader that actually doesn't use LoadLibrary but falls back to .Net default loader, giving meaningless Exception.

hope this helps others solve similar issues.

Odontoid answered 1/6, 2018 at 20:2 Comment(0)
M
0

None of the answers worked for me. It is a Windows Service application.

Based on accepted answer; I removed v8-ia32.dll & ClearScriptV8-32.dll (since my application is targeting x64)

It solved the issue.

Mosera answered 17/8, 2017 at 4:13 Comment(0)
G
0

Posted answers here did not work for me, but this did: Visual Studio -> Tools -> Options -> Project and Solutions -> Web Projects -> check "Use 64 bit version of IIS Express for web sites and projects"

Grattan answered 13/10, 2021 at 14:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.