1

I am started a project with ClearScript.V8. I am developing on Windows 10 & Visual Studio 2015 in C#. The web is IISExpress and this will eventually be released on a Windows 2012 server. I added the package ClearScript.V8 (v5.4.9) using NuGet. I always get the error below right from the start, not even initializing ClearScript yet (yes it's in french but it should be easy to understand):

Impossible de charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances. Le module spécifié est introuvable.

Description : Une exception non gérée s'est produite au moment de l'exécution de la requête Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code.

Détails de l'exception: System.IO.FileNotFoundException: Impossible de charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances. Le module spécifié est introuvable.

Erreur source:

Une exception non gérée s'est produite lors de l'exécution de la requête Web actuelle. Les informations relatives à l'origine et l'emplacement de l'exception peuvent être identifiées en utilisant la trace de la pile d'exception ci-dessous.

Trace de la pile:

[FileNotFoundException: Impossible de charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances. Le module spécifié est introuvable.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21 System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Impossible de charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances. Le module spécifié est introuvable.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +549

[HttpException (0x80004005): Impossible de charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances. Le module spécifié est introuvable.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10044576 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Informations sur la version : Version Microsoft .NET Framework :4.0.30319; Version ASP.NET :4.7.2046.0

I followed instructions from https://microsoft.github.io/ClearScript/Details/Build.html (especially section IV), so I have files ClearScript.dll, ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll and v8-x64.dll in my bin folder. I also have ClearScriptV8-32.dll and ClearScriptV8-64.dll in my root folder (with Copy to Output = Do not copy).

What am I missing?

pdube
  • 593
  • 1
  • 11
  • 26

1 Answers1

4

Try putting all of those DLLs (ClearScriptV8-*.dll, v8-*.dll) into the root folder, and make sure you do not have copies in bin. And if you're deploying onto a machine without Visual Studio (or with Visual Studio but without C++ support), install the appropriate version of Visual C++ Redistributable (it has to match the compiler used to build ClearScript).

BitCortex
  • 3,328
  • 1
  • 15
  • 19
  • Same issue with all files in root, no copies in bin. – pdube Jun 28 '17 at 13:02
  • Make sure you have `Copy to Output Directory` set to `Do not copy` for all of those files. If you're still seeing a problem at app startup (within `LoadAllAssembliesFromAppDomainBinDirectory`), post another stack trace. – BitCortex Jun 28 '17 at 13:18
  • This completely baffle me. Just to be sure I recreated a new project from scratch using Visual Studio 2015, added ClearScript.V8 and nothing else and still get the same error. I just don't understand how it's supposed to work if I move or duplicates DLL At some point you seem to suggest the web should not have any of the specified dll if there is no copy in bin and I don't copy to Output dir. Why does it try to use -32.dll if I run on x64? Why is this package so complicated to use when it should be straightforward? – pdube Jun 29 '17 at 19:33
  • The core problem is that these DLLs aren't managed. V8 is native, and ClearScriptV8 is mixed. At startup, ASP.NET pre-loads all DLLs in `bin`, and such DLLs make it fail. The solution is to remove them from `bin` and make sure they aren't copied there during deployment. Another solution is to exclude them from pre-loading (see [here](https://msdn.microsoft.com/en-gb/library/6st6fhzz(v=vs.100).aspx)). – BitCortex Jun 29 '17 at 20:16
  • See [here](https://stackoverflow.com/questions/15006449/error-could-not-load-file-or-assembly-oracle-manageddataaccessdtc-or-one-of-i) for a similar issue. – BitCortex Jun 29 '17 at 20:25
  • 1
    When I remove the files from bin, they reappear after a build. – pdube Jun 29 '17 at 22:14
  • 1
    Check for a custom build step that copies those files; sometimes NuGet packages add those. And, as I mentioned, if nothing else works, you should be able to exclude those files explicitly in web.config. – BitCortex Jun 30 '17 at 01:25
  • It starts to make more sense now. Thanks for all the explanations. I can't believe that, in 2017, there is no way to make a package that makes a standard build that checks if those files need to be copied (or at least that works in 95% cases). I don't have a development setup that is so special... For those looking here to get more info, the custom build steps are located in the project properties->Build Events->Post-build events. – pdube Jun 30 '17 at 02:07