I recently worked with a colleague on a ASP.NET MVC / Sitecore project that had some references to ClearScript, which is a 3rd party assembly that lets you add and run scripts from C#/.NET. We noticed issues with trying to publish files from the solution to the webroot, which always seemed to break the site. The most common issue was with ClearScript. These issues resurfaced as we refactored the solution and made subsequent QA deployments to the client’s servers.
The first thing we did to fix this was reinstall ClearScript and JSEngineSwitcher through Nuget. We then kept making code pushes to the webroot until we encountered a new error, which we usually had to install through Nuget as well, or troubleshoot/fix in other ways. Many of the assemblies were way out of date, since the solution had not been updated in a long time. Also, because the webroot was part of the solution, we found that some Nuget packages were installed into the webroot project, not the Web project that we were building out of, which also caused issues. To update this, we right clicked the solution and selected
Manage Nuget packages for this solution, then checked each package and clicked
Manage, and checked the box for the Web project.
We eventually got the code pushes to the webroot to work. The next problem was moving the code changes to QA. The main issue we ran into was an error stating
Could not load file or assembly 'ClearScriptV8-(32 or 64).DLL' or one of its dependencies. The specified module could not be found. Some solutions for this issue:
- Right click the IIS application pool and select Advanced Settings. Change the value for
Enable 32-bit Applicationsto true.
- Some people have had success with the opposite (setting it to false). I am still not sure what effect this value has.
- The error can mean that the ClearScript DLLs reference another DLL that is not present on the current machine. This makes sense considering I did not get this specific error on my machine with the same bin folder and site files. I looked into this and it seems like different versions of ClearScript require different versions of Visual C++ Redistributable:
- For ClearScript versions 5.0-5.3, install Visual C++ Redistributable 2012.
- For ClearScript versions 5.4 -?, install Visual C++ Redistributable 2013
- I installed both 32-bit and 64-bit versions of both, although I’m not sure if that was required.
- In my case, neither of the previous solutions worked, and it turned out that instead of copying over the bin to the QA server files and merging, I had to delete the bin folder and copy over new from my local webroot, which ended up fixing the issue.
I hope this helps others out there, this issue was quite an annoyance!