Clearscript files cannot be found on host

不羁的心 提交于 2019-11-28 21:16:23

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.

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>

...

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:

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

HRKoder

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!