# Using ClearScript. WebApplication problem

 LordBreetai Apr 1, 2013 at 7:32 PM Hi people, I'm traying to do a simple hello world example. My project is a web app. The idea is a simple page default.aspx where its page_load event define something like this: using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.ClearScript.V8; namespace WebTest { public partial class test_page: System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { try { var engine = new V8ScriptEngine(); } catch (Exception a) { Response.Write(a); } } } } Simple as create an instance of V8ScriptEngine and trying to do a "Hello world" via Response.write() from V8ScriptEngine. The problem is i'm getting an error in creation time of V8ScriptEngine. Using the WebServer for development supplied by VisualStudio.NET (IISExpress) invoking test_page.aspx on my browser, i'm getting this: System.TypeLoadException: Cannot load V8 proxy implementation type; verify that the following files are installed with your application: ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, v8-x64.dll at Microsoft.ClearScript.V8.V8Proxy.Create(String name, Boolean enableDebugging, Boolean disableGlobalMembers, Int32 debugPort) at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(String name, V8ScriptEngineFlags flags, Int32 debugPort) at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(String name, V8ScriptEngineFlags flags) at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(String name) at Microsoft.ClearScript.V8.V8ScriptEngine..ctor() at WebTest.test_page.Page_Load(Object sender, EventArgs e) it seems ClearScriptV8-32.dll, ClearScriptV8-64.dll are not founded so, adding references to ClearScriptV8-32.dll, ClearScriptV8-64.dll on my project and taking care of adding all dll (ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, v8-x64.dll) to the bin folder of my project i'm getting this: Server Error in '/' Application. -------------------------------------------------------------------------------- Could not load file or assembly 'ClearScriptV8-32.DLL' or one of its dependencies. The specified module could not be found. Stack Trace: [FileNotFoundException: Could not load file or assembly 'ClearScriptV8-32.DLL' or one of its dependencies. The specified module could not be found.] 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) +34 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) +16 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38 [ConfigurationErrorsException: Could not load file or assembly 'ClearScriptV8-32.DLL' or one of its dependencies. The specified module could not be found.] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +258 System.Web.Compilation.BuildManager.ExecutePreAppStart() +135 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516 [HttpException (0x80004005): Could not load file or assembly 'ClearScriptV8-32.DLL' or one of its dependencies. The specified module could not be found.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254  For some reason IISExpress can't locate 'ClearScriptV8-32.dll' or some dependencies. I have to say that i'm working with the 32-bit version of ClearScript full working on console testing. It seems console version of my testings (no IISExpress) is able to resolve bindings to dll's on execution time. Is it posible IISExpress or IIS 7.0 are unable to resolve this?? Someone is getting this error? What can I do? Thanks for your time. Lord ClearScript Coordinator Apr 2, 2013 at 1:29 PM Edited Apr 6, 2013 at 5:35 AM Hi Lord, Please give us a day or two to try to replicate your scenario. It does appear to be a simple issue of DLL placement, especially since the same DLLs work in the test console. Thanks! jbrantly Apr 2, 2013 at 7:59 PM We also ran into this and were able to track it down to shadow copying of assemblies in the bin directory. Basically the v8* files are not copied to locations that are easily referenced (not in the PATH, and not in the same directory as the loading assembly, such as ClearScriptV8-32.dll). We were able to work around it by turning off shadow copying using: ClearScript Coordinator Apr 3, 2013 at 4:16 AM Edited Apr 3, 2013 at 4:20 AM Thanks for your help jbrantly! We're going to publish an update very soon that changes how ClearScript loads V8, making it compatible with the assembly shadow copy feature. You'll then be able to add ClearScript to a web application simply by referencing ClearScript.dll and adding the rest of the DLLs as resource files at the root of the site. LordBreetai Apr 6, 2013 at 5:29 AM It works!!! :-D thanks people. My test project is working on ISSExpress, on IIS 7 not working yet, but is matter of specific configuration on ISS. THANKS!! lord urosemi Jun 22, 2013 at 2:41 PM Where you ever able to resolve your IIS 7 configuration? I am having similar problems. ClearScript Coordinator Jun 23, 2013 at 3:05 PM Hi urosemi, Can you provide a description of the specific problems you're having and what version of ClearScript you're using? You can find the ClearScript version in the Version.tt file in your ClearScript root directory. Thanks! urosemi Jun 23, 2013 at 9:22 PM Hi ClearScript, Thanks for following up! I actually figured out what the problem was with the help of Dependency Walker. I had built the ClearsScript V8 libraries with a debug configuration which requires some extra VC dlls that are not in the redistributable. I rebuilt in release mode and the problem was solved. Thanks for this project. I am using it for a productivity web app that allows power users to create custom reports using JavaScript. I investigated several other libraries but none of them integrated the .NET types so well. One of the features I was looking for was a way to allow users to dynamically set properties in JavaScript on a .NET dynamic object. IPropertyBag pretty much met my needs except that I also wanted to define some methods on the class and, as it says in the comments, only members in the collection are accessible by script code. I tried to to work around this by extending PropertyBag to reflect instance methods and add delegates as properties and it worked beautifully. With that in place I have been able to start developing a really nice scripting API for my application that takes advantage of the dynamic qualities of JS. Thanks again! ClearScript Coordinator Jun 24, 2013 at 1:05 PM Edited Aug 3, 2013 at 2:18 AM I tried to to work around this by extending PropertyBag to reflect instance methods and add delegates as properties and it worked beautifully. ​ One of our goals for PropertyBag was to give hosts complete freedom to define custom dynamic scriptable interfaces. That's why it supports delegate property values that act just like methods as far as script code is concerned. We really like your idea of using reflection to populate the collection with delegates that call normal methods in a derived class. That's very clever! By the way, we're working on improved host integration for an upcoming release. It'll give script code direct access to dynamic .NET objects such as ExpandoObject as well as custom dynamics derived from DynamicObject. It'll also streamline access to .NET dictionaries and other objects with custom indexers, so you'll be able to get your desired behavior simply by deriving from something like Dictionary and adding methods. Cheers! urosemi Jun 24, 2013 at 1:42 PM That is great! I will look forward to that release. Thanks! lolboxen Aug 22, 2013 at 3:41 PM Was clearscript ever made compatible with shadowcopy? I have 5.3.6 and shadow copy had to be disabled in order to work. ClearScript Coordinator Aug 22, 2013 at 4:05 PM Hi lolboxen, ClearScript looks for its auxiliary assemblies in several places. One of them is the AppDomain base directory. For a web application we recommend that, in addition to referencing ClearScript.dll normally, you add the V8 assemblies as resource files at the root of your project/site. This setup should work with assembly shadow copy. If this doesn't work for you, please let us know exactly what you did to integrate ClearScript into your project. Thanks! lolboxen Aug 22, 2013 at 4:15 PM That is basically how I have the project setup. Clearscript.dll is added as a reference, ClearScriptV8-32.dll and v8-ia32.dll are added as resources. These get copied to bin directory and as a byproduct of being in my project to the root of the site. I am using Visual Studio 2012 with IISEXPRESS ASP.NET 4.5 MVC4. Also clearscript was built using release configuration. In addition kudos to you guys for be very active in support. I sifted through several c# wrappers for JS engines and none were active. Keep up the good work. ClearScript Coordinator Aug 22, 2013 at 5:25 PM Thanks for your kind words! Unfortunately so far we haven't been able reproduce any issues with assembly shadow copy. If you leave it enabled, what symptoms do you see? We just created a new ASP.NET 4.5 MVC 4 application, added a reference to ClearScript.dll, added ClearScriptV8-32.dll and v8-ia32.dll to the project via "Add -> Existing Item...", and added a bit of code that uses V8ScriptEngine in Index.cshtml. The code worked correctly, and we verified that ClearScript.dll had been shadow-copied. Is there anything different about your configuration? lolboxen Aug 22, 2013 at 5:54 PM Ah I found the problem, those two files CANNOT be copied into the bin directory. They can ONLY exist in the root. ClearScript Coordinator Aug 22, 2013 at 7:12 PM Edited Aug 22, 2013 at 10:13 PM Ah, yes, we can see that setting ClearScriptV8-32.dll to "Copy Always" breaks the project, but we can't explain why. In that configuration the application can't start at all; we're even seeing it in a pristine new project with only that file added. Oh well, as long as there's an easy workaround :) niconico49 Nov 15, 2013 at 7:40 AM Edited Nov 15, 2013 at 7:43 AM Hi, I tried every configuration expose in this discussion, but my iis 7.5 refuse to load the library ClearScriptV8-32.dll or some dll dependence. I've tried that: 1) Install from nuget console with "Install-Package ClearScript.V8" 2) Console application: Ok, Web application: KO because iis complain with Impossile load file or assembly 'ClearScriptV8-32.DLL' o some relative dependencies 3) I have discovered the nuget installation add a reference to ClearScript.dll and a piece of code in vs project like this:  if not exist "$(TargetDir)" md "$(TargetDir)" xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.7.0\tools\native\x86*.*" "$(TargetDir)" if not exist "$(TargetDir)" md "$(TargetDir)" xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.7.0\tools\native\amd64*.*" "$(TargetDir)"  where, on the other hand, copy the .dll from downloaded directory to bin directory 4) I have tried some combination, like disable this piece of xcopy code, add the dll like resource in the visual studio project, enable, disable the inside web.config but iis refuse to load the library ClearScriptV8-32.DLL and v8-ia32.dll 5) now thanks to "Dependancy Walker" I discovered that file v8-ia32.dll (in windows 7) is linked with this dll list: API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL API-MS-WIN-CORE-WINRT-L1-1-0.DLL API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL DCOMP.DLL IESHIMS.DLL but, those files are not in windows\system32 (neither hidden) What does that mean? And is possible this is one of the problem? Thanks for help! niconico49 Nov 15, 2013 at 8:08 AM Edited Nov 15, 2013 at 8:10 AM I thought, that no is the problem beacuse in console application everiting is ok then i've tried this: definition a) xcopy part in project from dll downloaded to bin directory b) add dll as resource c) add inside web.config d) add dll inside project with simple "add item" (no resource) 1) only a) (simple installation by nuget) => impossible to load ClearScriptV8-32.dll or some reference 2) disabled a) => impossible to load ClearScriptV8-32.dll or some reference 3) b) and disabled a) => impossible to load ClearScriptV8-32.dll or some reference 3) c) and b) and disabled a) => impossible to load ClearScriptV8-32.dll or some reference 4) d) => error in the instantiation New V8ScriptEngine() inside source I'm very tired of this problem, what can i do? Thanks, Bye. ClearScript Coordinator Nov 15, 2013 at 11:32 AM Edited Nov 15, 2013 at 11:37 AM Hi niconico49, 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 as content files at the root of your web application. You should be able to find them in$(SolutionDir)packages\ClearScript.V8.5.3.7.0\tools\native\[x86|amd64]. Make sure their "Copy to Output Directory" properties are set to "Do not copy". Make sure that either Visual Studio 2012 or the Visual C++ Redistributable for Visual Studio 2012 is installed on your deployment machine(s). Please let us know if this works for you. If it doesn't, please consider making an archive of your project available to us for analysis. By the way, that dependency list for v8-ia32.dll is definitely incorrect. The command "link /dump /dependents v8-ia32.dll" provides the correct list, which is quite short: MSVCR110.dll, KERNEL32.dll, WS2_32.dll, and WINMM.dll. Good luck! prgjonas Nov 25, 2013 at 6:54 AM Hi, I tried the workaround described but could not get it working. Could be I reference another project with the clearscript assemblies in it? I did not put very much time into it yet. Anyway, it would certainly be good to have a nuget that works for asp net ootb. The performance when calling a javascript function with the help of ClearScript is great, it should be a lot of use for this in asp net sites. For example to use any js template engine as a asp net mvc view engine. Thanks ClearScript Coordinator Nov 25, 2013 at 12:36 PM Greetings prgjonas! The procedure above has been used successfully to deploy ClearScript with ASP.NET applications in both IIS and Azure. If it doesn't work for you, we'd love to take a look at your project (or a relevant subset) if that's a possibility. As for the NuGet package, we don't maintain it. Please consider contacting its owner, either here or at nuget.org. Good luck! niconico49 Dec 10, 2013 at 1:11 PM Sorry for my late but i have tried the configuration suggested: 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 as content files at the root of your web application. You should be able to find them in$(SolutionDir)packages\ClearScript.V8.5.3.7.0\tools\native[x86|amd64]. Make sure their "Copy to Output Directory" properties are set to "Do not copy". Make sure that either Visual Studio 2012 or the Visual C++ Redistributable for Visual Studio 2012 is installed on your deployment machine(s). and when i execute visual studio in debug mode, in this instruction: dim v8engine As V8ScriptEngine = New V8ScriptEngine() i have the following exception: An exception of type 'System.TypeLoadException' occurred in ClearScript.dll but was not handled in user code Additional information: 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 thanks for help. Bye ClearScript Coordinator Dec 10, 2013 at 1:33 PM Hi niconico49, Can you tell us more about your project? It appears to be an ASP.NET application written in Visual Basic; is that correct? Are you running into this problem when deploying on your development PC or on another server? Would you consider sharing (part of) your code to help us diagnose the issue? Thanks! niconico49 Dec 10, 2013 at 1:46 PM yes is a vb.net project and running in this problem when i launch in my development pc. Now i've never try to deploy in a iis server, obsiously!! On the other hand now i try to download the latest version 5.3.10 of the clearscript, and then try to recompile with v8-support and launch the project in vs 2013 express with the same configuratione... if i have the same problems, the next things to do is to make a little web project to share stay tuned. :) thanks. bye ClearScript Coordinator Dec 11, 2013 at 12:25 AM Great! Please let us know if you continue experiencing problems after the updates. niconico49 Dec 11, 2013 at 10:57 AM Edited Dec 11, 2013 at 11:01 AM I download / recompile and launch everything and the problem is in this instruction inside VBProxy.cs: hLibrary = NativeMethods.LoadLibraryW(path); inside this function: private static bool LoadNativeLibrary()  { var hLibrary = IntPtr.Zero; var suffix = Environment.Is64BitProcess ? "x64" : "ia32"; var fileName = "v8-" + suffix + ".dll"; var paths = GetDirPaths().Select(dirPath => Path.Combine(dirPath, fileName)).Distinct(); foreach (var path in paths) { hLibrary = NativeMethods.LoadLibraryW(path); if (hLibrary != IntPtr.Zero) { break; } } return hLibrary != IntPtr.Zero; }  but in one path inside the foreach loop ther is EXACTLY the CORRECT path of dll and then the question is: Why the LoadLibraryW(path) (or LoadLoalibray(path) because i've tried this too) doesn't load the library? inside the same source there is:  private static class NativeMethods { [DllImport("kernel32", ExactSpelling = true)] public static extern IntPtr LoadLibraryW( [In] [MarshalAs(UnmanagedType.LPWStr)] string path ); }  and because i have windows 7 32 bit is possible that the problem is linked with the kernel32 some unknown and strange behaviour??????? ClearScript Coordinator Dec 11, 2013 at 2:04 PM Hi niconico49, ​ but in one path inside the foreach loop ther is EXACTLY the CORRECT path of dll and then the question is: Why the LoadLibraryW(path) (or LoadLoalibray(path) because i've tried this too) doesn't load the library? ​ This issue has been reported several times, and the cause is always the same - the library can't be loaded because it depends on another library that can't be found. In all the cases we've investigated so far, the Visual C++ library (msvc*.dll) was the missing piece. The cause was that neither Visual Studio nor the Visual C++ Redistributable Packages were installed. If you're seeing this problem on a PC with Visual Studio installed, then we have no explanation because we can't reproduce the problem. We'd love to diagnose it for you, but to do that we might have to take a look at your project. If that's not possible, then we can try to continue by asking more questions. Can you provide the path to the library that fails to load? Feel free to change any directory names that you'd prefer not to reveal. Also, did you build ClearScript, or are you still using the NuGet package? Finally, are you still trying to run your application on your development PC? Thanks! niconico49 Dec 12, 2013 at 8:39 AM Edited Dec 12, 2013 at 8:45 AM i had installed vs 2013 express and Visual C++ Redistributable Packages 2013 downloaded from here: http://www.microsoft.com/it-it/download/details.aspx?id=40784 i downloaded the clearscript package from this site and create ClerScriptV8 project with this phase 1) open the vs prompt by this .bat in this location, link in desktop: "%comspec% /k "C:\Program Files\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" 2) i go to the directory whe i unzipped the ClearScript project by cd , cd etc.. and launched the V8Update.cmd by the command "V8Update /N" 3) after the creation of v8 project (obviously i had svn installed) i opened by vs2013 express (c++) and compile 4) I copied the all 5 dll (ClearScript, v8-ia32, v8-x64, ClearScriptV8-32, ClearScriptV8-64) in a directory of my web project (vs 2013 vb.net in that case) and added ClearScript as reference and the other 4 dll as resource by select the project (and not the solution) ==> mouse right button ==>add item and select the four dll with this property settings: Copy to Output Directory" properties are set to "Do not copy". 5) after i executed the project, and thanks to the ClearScript.sln (with v8 support obviously) opened i saw the error exposed before, where the path computed in the foreach loop was: first: the temporary .net directory: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\\9eb5f2bd\26824334\assembly\dl3\fc7e457e\3ea5541e_1cf7ce01\v8-ia32.dll second: the root directory of my project (where infact i included the 4 dll as resource, the path was correct, but the NativeMethods.LoadLibraryW(path); doesn't like third: the bin directory of my project, where the nuget tried to copy by the following task, that i disabled:
not satisfied i tried the same in a DESKTOP PROJECT and the result was ok with any kind of tempt: 1) with the copy of the dll in the bin by the: if not exist "$(TargetDir)" md "$(TargetDir)" xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.10.0\tools\native\x86*." "$(TargetDir)" if not exist "$(TargetDir)" md "$(TargetDir)" xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.10.0\tools\native\amd64.*" "$(TargetDir)" 2) without the point 1) but added the dll as resource in the project after all this I suppose, like this entire Discussion, that is not a problem of Visual C++ Redistributable Packages but that in web project/solution the: NativeMethods.LoadLibraryW(path); doesn't load the library and then: WHY???????????????????????????????????????? sincerely i'm very fed up!!! but is not possible to have a single dll with all and avoid the dll hell or in other case two dll clearScript_32 and clearscript_64 to use as reference in function of the operative system, and nothing else? niconico49 Dec 12, 2013 at 9:16 AM Edited Dec 12, 2013 at 9:46 AM Another idea: If I'll create a desktop project (console application) or a Class Library (but for this i don't know if ClearScript doesn't have problem) that use clearscript and add this as reference to my web project/solution, for you is possible to avoid (and solve) all the problem exposed in this topic / discussion? Now i've tried this, but obvsiously the web project create the dll of the project included and expose the same problem: TEMPT FAILED!!!!!!!!!!!!!!!!!!!!!!!!! OTHER IDEA? HAVE SOME OTHER SOLUTION IN MIND? Bye and Thanks!!! ClearScript Coordinator Dec 12, 2013 at 2:35 PM Hi niconico49, Thanks for providing so many details. We're sorry to hear that this issue is still blocking you, but we still can't reproduce it. On a machine running 32-bit Windows 7 and Visual Studio 2012, we created a Visual Basic ASP.NET project, added a reference to ClearScript.dll, added the other DLLs as content files at the root, and added some code that invokes the V8-based script engine and displays the result in the home page. Everything just works. Can you think of anything else about your project that might be different or non-standard in any way? If you can't share your project, one thing we could do is give you a slightly modified version of ClearScript that collects error information returned by the LoadLibraryW function. Are you interested in trying that? It might provide a clue. Thanks! niconico49 Dec 12, 2013 at 4:00 PM Infact i thought about that request: a piece of code where there is an error control about the result of LoadLibraryW i tried to use getlasterror but because i don't know the library to include and the howto to use the code, your solution will be very helpful for me!!! In that case i'll wait for the version of clearscript or, if is more simple for you the piece of code or the class modified VBProxy.cs it's your choice, thanks. On the other hand, can you try the same test with Visual Studio 2013 express too? In any case the question is the same: i'll wait for a version modified of clearscript to obtain the control errors. Thanks anyway. Bye ClearScript Coordinator Dec 12, 2013 at 7:53 PM Please try the following in V8Proxy.cs. First, make sure the NativeMethods class looks like exactly like this: private static class NativeMethods { [DllImport("kernel32", ExactSpelling = true, SetLastError = true)] public static extern IntPtr LoadLibraryW( [In] [MarshalAs(UnmanagedType.LPWStr)] string path ); }  Then, in LoadNativeLibrary, call Marshal.GetLastWin32Error to get the error code when LoadLibraryW fails. For example, the loop might look something like this: foreach (var path in paths) { hLibrary = NativeMethods.LoadLibraryW(path); if (hLibrary != IntPtr.Zero) { break; } var error = Marshal.GetLastWin32Error(); Console.WriteLine(error); // breakpoint here }  Remember to rebuild everything and update the ClearScript files in your web project. You should then be able to set a breakpoint at the location indicated above and examine the error code. Please let us know what you find! Thanks! niconico49 Dec 13, 2013 at 8:39 AM Edited Dec 13, 2013 at 9:07 AM I've tried to use the error control and, strange, the only thing i have obtained is error = 0...... After this, i tried to only change location of my project and, finally everything was OK!!!!!!!!!!!!!!!!!!!!! Then i investigated and discovered that the problem was in the path of the location of the project and precisely the presence of "." and/or the "-" character (dot and/or minus to explain). For example my path was like: C:\Users\development.word1-word2\Desktop\ProjectName To conclude i suppose the NativeMethods.LoadLibraryW(path); method doesn't like this strange characters in the path of directory of various dll location and in that case is a LoadLibraryW BUG!!! And for this, how solve this Bug? In any case thanks for the help. Bye!!!! ClearScript Coordinator Dec 13, 2013 at 12:02 PM I've tried to use the error control and, strange, the only thing i have obtained is error = 0...... ​ Hmm, are you sure you have SetLastError=true on the DllImport attribute? ​ To conclude i suppose the NativeMethods.LoadLibraryW(path); method doesn't like this strange characters in the path of directory of various dll location and in that case is a LoadLibraryW BUG!!! ​ This is all very odd. We've tried to replicate your environment by creating a user account with periods and dashes in the name. We then created the VB web project in that user's directory, ensuring that the path to the project included periods and dashes. But we still couldn't reproduce the problem. In any case, we're very happy to hear that you found a way forward! Please let us know if you encounter any other issues. Thanks! niconico49 Jan 20, 2014 at 7:53 AM Edited Jan 20, 2014 at 7:55 AM Hi, this time i have the same problem in an iis 7.5 or in other hand: 1) the project is ok in my pc when i have vs 2013 express, iis 7.5 and vs redistribuitable installed (thanks to vs, i suppose) 2) I had tried to install the project in iis 7.5 in another machine but i had this segnalation: error ==> "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\",\"ExceptionType\":\"System.TypeLoadException\",\"StackTrace\":\" in Microsoft.ClearScript.V8.V8Proxy.GetImplType(Type type)\r\n in Microsoft.ClearScript.V8.V8Proxy.CreateImpl[T](Object[] args)\r\n in Microsoft.ClearScript.V8.V8Runtime..ctor(String name, V8RuntimeConstraints constraints, V8RuntimeFlags flags, Int32 debugPort)\r\n in Microsoft.ClearScript.V8.V8Runtime..ctor(String name, V8RuntimeConstraints constraints, V8RuntimeFlags flags)\r\n in Microsoft.ClearScript.V8.V8ScriptEngine..ctor(V8Runtime runtime, String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, Int32 debugPort)\r\n in Microsoft.ClearScript.V8.V8ScriptEngine..ctor(String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, Int32 debugPort)\r\n in Microsoft.ClearScript.V8.V8ScriptEngine..ctor(String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags)\r\n in Class in this instruction: v8engine = New V8ScriptEngine() 3) i installed the vs 2013 redistribuitable and vs 2012 redistribuitable too and not only i had tried that in two machine: one 32bit like my workstation in point 1) and another one 64bit (when i installed the 64bit of vs 2013 redistribuitable and vs 2012 redistribuitable too and not only the 32bit version), bu NOTHING: I HAD the above segnalation...... 4) what can i do? or what is the difference? (in the other two machines there aren't vs installed but only the vs 2012/2013 redistribuitable tool......) on the other hand i have tried to set this option:  but in my machine (with vs) everithing remain ok, but in ther other machines NO... 5) I have tried to use the tool of export/import application in the iis 7.5 to, i hope, avoid to lost some configuration, but nothing has changed. Can you help me, please? Thnaks for all, Bye. ClearScript Coordinator Jan 20, 2014 at 12:38 PM Hi niconico49, A couple of questions: Are you still using ClearScript via a NuGet package? Can you describe exactly how you're deploying your project to the external IIS 7.5 server? Thanks! niconico49 Jan 20, 2014 at 12:55 PM Edited Jan 20, 2014 at 1:05 PM 1) absolutely not!! this morning i've tried to copy my project and use nuget but in that case after the WEB project launch i've obtained the same error in the local machine, and then i used the original settings: use the dll as resource, avoid the xcopy in the project (normally setted by nuget for example) .... 2) after i'have execute my project in my local machine (with iis 7.5 too) i deploy the entire project by the tool "export application" in iis in my amchine to obtain a zip file, and import in the iis 7.5 in the other machine (32bit like mine for now) by the iis tool "import application"; and then, in the project "deployed" (if is correct to say) i saw that the dll library are in the correct position, ClearScript inside the "bin" and the othe dll "ClearScriptV8-32", "ClearScriptV8-64", "v8-ia32", "v8-x64" in the root/home site (main directory) ClearScript Coordinator Jan 21, 2014 at 2:52 AM We're investigating and will have more info (or more questions) soon. Thanks for your help. BuildStarted Jan 24, 2014 at 1:02 AM Edited Jan 24, 2014 at 1:17 AM So here's what's wrong with the NuGet package when dealing with websites. You have two post-build events that copy the files to the bin directory when for websites they need to be moved to the project directory instead. The choice answer here would probably be to create a web specific NuGet package. I've created one locally that does exactly what needs to be done and it works flawlessly. $solutionDir = [System.IO.Path]::GetDirectoryName($dte.Solution.FullName) + "\" $path =$installPath.Replace($solutionDir, "$(SolutionDir)") $NativeAssembliesDir = Join-Path$path "tools\native" $x86 =$(Join-Path $NativeAssembliesDir "x86\*.*")$x64 = $(Join-Path$NativeAssembliesDir "amd64\*.*") $PostBuildCmd = " if not exist "$(ProjectDir)" md "$(ProjectDir)" xcopy /s /y "$x86" "$(ProjectDir)" if not exist "$(ProjectDir)" md "$(ProjectDir)" xcopy /s /y "$x64" "\$(ProjectDir)"" For now I've created a NuGet package that depends on ClearScript but then just appends del commands to remove those files copied and copies them to the right location. hacky... ClearScript Coordinator Jan 24, 2014 at 11:26 AM Thanks for looking into this. We're still trying to reproduce niconico49's exact setup and deployment method. ClearScript Coordinator Jan 25, 2014 at 6:12 PM We reproduced the issue, or at least an issue with the same symptoms, on the local IIS server. It turned out that the V8 libraries couldn't be loaded because of a permission issue. Changing the application pool identity fixed the problem. Obviously, manual loading of the V8 assemblies can fail for many reasons, and ClearScript currently reports the same error for all of them. This is something we're going to fix in the next release. niconico49 Feb 12, 2014 at 10:29 AM any feedback, have you reproduced and, finally, solved the problems? Thanks a lot. ClearScript Coordinator Feb 12, 2014 at 11:21 AM Hi niconico49, Sorry we didn't make this clear. Yes, we reproduced the issue, and in our case the problem was permissions. The assemblies were in the right place but the application pool identity couldn't access them. Because we can't provide a universal fix for deployment issues like this, we're working on enhanced error reporting. Instead of the unhelpful message you currently see, the next version of ClearScript will list the directories it searched for the V8 assemblies and the error encountered in each one. Cheers! danielearwicker Mar 24, 2014 at 9:34 PM I encountered the error caused by LoadAllAssembliesFromAppDomainBinDirectory trying to load every single assembly in the bin directory (as its name suggests!). But I found that I could stop ASP.NET from loading specific assemblies, like this:   With that change to my Web.config, I find no other changes are needed. I didn't have to reference ClearScript directly from my web app project, or add the ClearScript auxiliary V8 DLLs to the root of the project as non-copying resources. ClearScript Coordinator Mar 25, 2014 at 3:45 PM Hi danielearwicker, Thanks you very much for posting your findings! Cheers! danielearwicker Mar 27, 2014 at 11:50 AM Another observation: SQL Compact for .NET places only the architecture-neutral API assembly in the normal load path (e.g. webapp\bin). It has x86 and x64 subdirectories (e.g. webapp\bin\x86) for everything else. Presumably this means the fixed-bitness DLLs are not inadvertently loaded by ASP.NET. willeyams May 29, 2014 at 4:24 AM This issue seems a bit of an epic. I've read through and tried a lot of things here, but I'm still unable to run my website. Installed via NuGet package (bear with me, I don't think that's the issue -- I even updated this morning) Works fine in VS 2013 express on development machine Works fine in IIS7 on development machine ClearScript v5.3.11.0 Doesn't run on the server after using web deploy to deploy (debug or release) Server is Windows 2008 R2 Datacenter w/ Web Server Role (IIS7) Actual error is Cannot load V8 interface assembly. Load failure information for v8-x64.dll: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\d007e065\a07c7d1b\assembly\dl3\3b1d0932\880b1e76_0e75cf01\v8-x64.dll: The specified module could not be found C:\inetpub\mysite.com\beta\v8-x64.dll: The specified module could not be found C:\inetpub\mysite.com\beta\bin\v8-x64.dll: The specified module could not be found The files do not exist in the paths mentioned. They do exist in /bin/ClearScript.V8/ The dll ClearScript.dll does exist in /bin/ I did try quite a few things: Copying the requested dlls into the requested paths also generated errors (mentioned in other, older posts) Turning off shadow copy only removed the line about Temporary ASP.NET Please help, I've spent a whole day on this so far. andrea_schirru May 29, 2014 at 8:54 AM Edited May 29, 2014 at 9:03 AM Hi willeyams, you can use the AssemblyResolve event to point your application to the correct binaries. I've deployed successfully my ASP.NET application to Azure with this technique. First, you register the event handler in the Application_Start method of your website like this:  void Application_Start(object sender, EventArgs e) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; } This is the way I'm handling the loading:  Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { if (args.Name.Contains("ClearScript")) { var rootPath = HostingEnvironment.MapPath("/Dependencies"); try { _log.Info("Looking for ClearScript in " + Path.Combine(rootPath, "ClearScriptV8-64.dll")); return Assembly.LoadFile(Path.Combine(rootPath, "ClearScriptV8-64.dll")); } catch (Exception e) { _log.Error("Cannot load ClearScript64", e); return Assembly.LoadFile(Path.Combine(rootPath, "ClearScriptV8-32.dll")); } } return null; } Clearly, my /Dependencies directory contains ClearScriptV8-xx.dll as well as v8-xxx.dll (which is probably needed only if you are using V8). Let me know if this helps! Also, note that the assembly resolve event is probably not handled by the NuGet version (which is not officially supported by the developers) - you'll have to get a version from Codeplex. Best regards, Andrea edit: since this is my first post, I'd like to thank the developers of ClearScript for providing such an amazing package. Keep up the good work :-) ClearScript Coordinator May 29, 2014 at 1:52 PM Hello andrea_schirru! Thank you very much for posting that sample, and for your kind words! Cheers! willeyams May 29, 2014 at 5:54 PM Edited May 29, 2014 at 6:11 PM andrea_schirru, thanks so much for the suggestion. i put in the code and updated your /Dependencies path to my /bin/ClearScript.V8 path. after this implementing this, i first got the versioning error. this is because the 64bit was throwing the "cannot find" error and then tried loading the 32bit version. this was bad news. what was exciting was that it seemed to be able to find the 32bit version. so i commented out the try/catch and i'm back to the same error. everything still works on my local machine, in VS and running straight from IIS. i verified that the code is being executed (by attaching to local IIS process) the one thing i don't understand in your post is the comment about the NuGet version not handling the assembly resolve event. it looks to me like that's being handled by global.asax.cs, not the ClearScript dll. then again, the paths in the error aren't updating to what's being supplied in the rootPath variable. for kicks, i turned shadow copying off (which just eliminates the temp directory part of the message) then i copied the dlls into the bin folder since that's where it seems to want them, and of course this gives me version issues bc of the 32bit one Could not load file or assembly 'ClearScriptV8-32' or one of its dependencies. An attempt was made to load a program with an incorrect format. and if i remove the 32bit dlls i get, Could not load file or assembly 'ClearScriptV8-64.dll' or one of its dependencies. The specified module could not be found. i'm going to see if i can find the CodePlex versions of the dlls you mentioned and i'll let you know how that works. brad willeyams May 29, 2014 at 6:36 PM Edited May 29, 2014 at 6:36 PM hello again, everyone. it's time for me to admit to a n00b mistake. C++ redistributable wasn't installed. (as is mentioned several times in this post) it needed both the x64 and x86 version of the Visual C++ 2012 installed. from now on, i'll know that's what The specified module could not be found.` means. THANKS EVERYONE! ClearScript Coordinator May 29, 2014 at 6:41 PM Hi brad, In case you missed it, if Visual Studio is not installed on your deployment machine, you must install 32-bit and 64-bit Visual C++ Redistributable packages: Visual C++ Redistributable for Visual Studio 2012 Visual C++ Redistributable for Visual Studio 2013 The version you need depends on which version of Visual Studio was used to generate your ClearScript binaries. If you're using a NuGet package and aren't sure, you should be able to install both sets side-by-side. Good luck! offshoredevpune Dec 5, 2014 at 2:34 PM Hello, I recently started using ClearScript. I have used ClearScript.Manager through Nuget package. I am using Visual Studio 2012. I could see 'ClearScriptV8-32'.dll', 'ClearScriptV8-64.dll', 'v8-ia32.dll' & 'v8-ia64.dll' added in the project. It got copied over to bin directory while running app. But I see below error: Could not load file or assembly 'ClearScriptV8-32.dll' or one of its dependencies. The specified module could not be found. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'ClearScriptV8-32.dll' or one of its dependencies. The specified module could not be found. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [FileNotFoundException: Could not load file or assembly 'ClearScriptV8-32.dll' or one of its dependencies. The specified module could not be found.] 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) +34 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) +16 System.Reflection.Assembly.Load(String assemblyString) +28 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38 [ConfigurationErrorsException: Could not load file or assembly 'ClearScriptV8-32.dll' or one of its dependencies. The specified module could not be found.] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285 System.Web.Compilation.BuildManager.ExecutePreAppStart() +153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516 [HttpException (0x80004005): Could not load file or assembly 'ClearScriptV8-32.dll' or one of its dependencies. The specified module could not be found.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9915300 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254 Am I missing anything here? I created a simple ASP.net application to test this. If you need, I can provide the source. offshoredevpune Dec 5, 2014 at 2:38 PM Update to above thread. I am using Azure to deploy. It is working fine there. ClearScript Coordinator Dec 5, 2014 at 3:01 PM Hi offshoredevpune, A couple of suggestions: ​ Make sure that the "Copy to Output Directory" properties for those DLLs are set to "Do not copy". For some reason mixed-mode and native modules just don't work if copied to the bin directory. It appears to be an ASP.NET limitation. ​ Consider getting a newer version of ClearScript for more detailed error reporting in this specific scenario. If ClearScript fails to load any of those modules, it'll list the places it looked and the errors it encountered. Thanks! offshoredevpune Dec 6, 2014 at 5:28 AM Edited Dec 6, 2014 at 5:28 AM I tried above 2 suggestions, but it didn't work. I am running latest version of ClearScript.Manager i.e. 1.2.0.17920 Thanks ClearScript Coordinator Dec 8, 2014 at 3:14 PM Hi again, A couple more things: ​ Make sure those DLLs are not in the "bin" directory. ​ If you're deploying to a server that doesn't have Visual Studio installed, it must have the Visual C++ Redistributable Package installed (VS2012, VS2013). Be sure to install the 32- and/or 64-bit version as necessary. Thanks! andrea_schirru Dec 10, 2014 at 3:36 PM Did you try to resolve the dependencies with the AssemblyResolve event? I've described the procedure a few posts up in this same thread.