Search code examples
asp.net-mvc-4iisdeploymentshared-hostingclearscript

Clearscript files cannot be found on host


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.


Solution

  • 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.