Clearscript files cannot be found on host - asp.net-mvc-4

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.

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:
ClearScript Versions 5.0 - 5.3: Visual C++ Redistributable for Visual Studio 2012
ClearScript Versions 5.4 - .....: Visual C++ Redistributable for Visual Studio 2013

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

If you're deploying on Windows Server 2012 with IIS role, there are two things you should do to get ClearScriptV8 running:
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
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:
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.

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.

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.

Posted answers here did not work for me, but this did:
Visual Studio -> Tools -> Options -> Project and Solutions -> Web Projects -> check "Use 64 bit version of IIS Express for web sites and projects"

Related

The "TransformWebConfig" task failed unexpectedly - System.Exception: The acceptable value for AspNetCoreModuleHostingModel property is either

I get
'The "TransformWebConfig" task failed unexpectedly. System.Exception: The acceptable value for AspNetCoreModuleHostingModel property is either "InProcess" or "OutOfProcess".'
error while publishing an ASP.NET Core 2.2.0 application (actually it is the included sample application) for win-x64 environment. Both Visual Studio 2017 and 2019 gives the same error. I am working on Windows 10. What should I do to solve this?
Last part of publish Output is:
c:\users\engin\source\repos\NetCoreWebApplication2\NetCoreWebApplication2\obj\Release\netcoreapp2.2\win-x64\PubTmp\Out\
C:\Program Files\dotnet\sdk\2.2.200-preview-009648\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): Hata MSB4018: "TransformWebConfig" görevi beklenmedik biçimde başarısız oldu.
System.Exception: The acceptable value for AspNetCoreModuleHostingModel
property is either "InProcess" or "OutOfProcess".
konum: Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.TransformAspNetCore(XElement aspNetCoreElement, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel)
konum: Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.Transform(XDocument webConfig, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel, String environmentName)
konum: Microsoft.NET.Sdk.Publish.Tasks.TransformWebConfig.Execute()
konum: Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
konum: Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2 Derleme başarısız oldu. Daha fazla ayrıntı için çıktı penceresini denetleyin.
========== Oluşturma: 1 başarılı, 0 başarısız, 0 güncel, 0 atlandı ==========
========== Yayın: 0 başarılı, 1 başarısız, 0 atlandı ==========
I would suggest disabling web.config transforms altogether. In an ASP.Net Core project you probably do not need to transform web.configs since supplying environment variables is handled by convention with appsettings.[Environment].json files.
From the docs at https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2:
To prevent the Web SDK from transforming the web.config file, use the <IsTransformWebConfigDisabled> property in the .csproj file:
<PropertyGroup>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
I had the same problem and found the solution
In the csproj file, find following line and delete.
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Had the same issue on .net core 2.2.104. Update the section to this:
<AspNetCoreHostingModelV2>InProcess</AspNetCoreHostingModelV2>
Note the V2 addition.
The answer #Barış Bar provided is working but can cause future errors. There is a bug about UpperCases. Just change InProcess in csproj file with lowercase
<AspNetCoreHostingModel>inprocess</AspNetCoreHostingModel>
It is said that the bug will be corrected in VS 2019.
InProcess or OutOfProcess
Just add this line to your web.config file
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
For me, there was a permission issue which is why, while publishing, a transformation task was running on web.config file. That file did not had access for normal user.
Closing Visual Studio and running it as Administrator then publishing the project worked for me or you can try on setting the correct permissions for the problematic file.
After successfully publishing the project once with administrator privileges, visual studio started working with normal users as well (weird though but good).
UPDATE:
Stumbled into the same problem again, and this time it was not resolved by the above solution, I had to check back the project directory and some of the files were marked Read-Only had to change it to get it working. I suppose this is a problem with the TFS which gets the files and sets them as Read-Only.
My .NET Core 2.2 application build was failing on Jenkins but it was working fine on local machine.
Error: error MSB4018: The "TransformWebConfig" task failed unexpectedly.
Fix: Removed below line from .csproj file
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
I had a project in TFS, due to some issues, the TFS went down and when I made it go online again, it failed to publish the project, while the debugging worked fine. It caused the error (The TransformWebConfig task failed unexpectedly).
After checking the output window, it seemed some files were not accessible to visual studio, or were protected. So, it was because of the TFS, all or most of the files in the project were set as Read-Only which is why Visual Studio couldn't transform those files.
Removing the Read-Only flag from the project fixed the publishing problem.
find the project file (.csproj) and update this code
<AspNetCoreHostingModel>OutProcess</AspNetCoreHostingModel>
to this
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Adding this to the .csproj file did it for me:
<PropertyGroup>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
If you are upgrading your .net core version from 3.1 to higher framework, please check web.config aspNetCore node
The attribute hostingModel should be inprocess (all small case) vs InProcess in .netcore 3.1 framework
This change worked for me and able to publish my project.

MSBuild 15: The "Error" task could not be instantiated

I'm attempting to programmatically build a project which uses C#7, and therefore MSBuild 15, but this task is failing seemingly because of mismatched assembly references.
Here is my code:
string projectFilePath = Path.Combine(args.Any() ? args.First() :#"C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln");
ProjectCollection pc = new ProjectCollection();
Dictionary<string, string> globalProperty = new Dictionary<string, string>();
globalProperty.Add("Configuration", "Debug");
globalProperty.Add("Platform", "x86");
BuildParameters bp = new BuildParameters(pc);
bp.Loggers = new ILogger[] { new Logger(), new ConsoleLogger(), };
BuildRequestData BuidlRequest = new BuildRequestData(projectFilePath, globalProperty, "4.0", new string[] { "Build" }, null);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(bp, BuidlRequest);
Here is the error message:
C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln.metaproj : error MSB4127: The "Error" task could not be instantiated from the assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.Error' to type 'Microsoft.Build.Framework.ITask'.
C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln.metaproj : error MSB4060: The "Error" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.
Here is a link to a project you can use to recreate the issue:
https://drive.google.com/a/xibis.com/file/d/0B-mqMIMqm_XHcVRJQmtxQkd1b3c/view?usp=sharing
You will have to change the path in the code to a project on your own machine, but it doesn't seem to matter if this is a VS 2017 project or earlier.
One other thing that may or may not be relevant, I noticed that the Microsoft.WebApplication.Build.Tasks.Dll in this folder:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications
Still seems to be referencing Microsoft.Build.Framework.dll version 14, not 15 as I would have expected.
It turns out there are two issues in my test project. The first is due to the naming of the project.
However there is a second issue which is due to the references not being correct. To use MSBuild 15 programmtically you must install the following packages:
Install-Package Microsoft.Build -Version 15.1.1012
Install-Package Microsoft.Build.Framework -Version 15.1.1012
Install-Package Microsoft.Build.Tasks.Core -Version 15.1.1012
Install-Package Microsoft.Build.Utilities.Core -Version 15.1.1012
Install-Package Microsoft.Net.Compilers -Version 2.2.0
There is one more step which is nuts and completely undiscoverable. You must now add a reference to this DLL which should be relative to your solution folder:
packages\Microsoft.Net.Compilers.2.2.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll
I opened a support ticket with Microsoft and they have confirmed that this is a bug in Visual Studio 2017.
They are aiming to get a fix for this into update 3 for Visual Studio, but this may slip.
This issue tracks the bug:
https://github.com/Microsoft/msbuild/issues/2194
There is no workaround at present for this API, but you can invoke the MSBuild exe using Process as an alternative.
If you have MSBuild installed on your PC, either directly or through Visual Studio, the proper fix is to use the package Microsoft.Build.Locator which will find that installed version and execute the build using it.
Install these packages
Microsoft.Build
Microsoft.Build.Framework
Microsoft.Build.Locator
The first 2 are needed so that the code can compile but should be excluded from the project output.
In your application startup add the following line of code, this only has to run once.
Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults();
Remove any additional binding redirects in your app.config that are specific to Microsoft.Build or other build libraries. The call to the Microsoft.Build.Locator assembly will ensure that these redirects take place automatically.
References
Update an existing application for MSBuild 15
Github MSBuildLocator.

Unable to load dynamic library php_sqlsrv_7_nts.dll is not a valid Win32 application

Thought I'd see if there were any sql server drivers for php 7. Another question on Stack Overflow pointed me to these drivers here
So I install php_sqlsrv_7_nts.dll into my ext folder and add the following line to my php.ini:
extension=php_sqlsrv_7_nts.dll
I get this warning on every php script I run:
Warning: PHP Startup: Unable to load dynamic library 'C:\php7\ext\php_sqlsrv_7_nts.dll' - %1 is not a valid Win32 application
I realise this is just a pre-release version and there are many things to iron out still, but I was hoping to at least do some basic things.
What am I doing wrong, or do I need to wait a bit more for a better release.
Some info that might be useful:
PHP Version => 7.0.5
System => Windows NT GB275L-I-T-5654 6.3 build 9600 (Windows 8.1 Professional Edition) i586
Build Date => Mar 30 2016 09:57:56
Compiler => MSVC14 (Visual C++ 2015)
Architecture => x86
Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo"
Finally got this solved. Needed to install some more things before it would work, namely:
Microsoft Visual C++ 2015 Redistributable (x86) which you can get from here
The ODBC drivers which you can get from here
It works for me.
1.Download the extension windows 7.0
https://github.com/Microsoft/msphpsql/releases
2.And then according to the system requirement paste it in ext folder.
Note: Paste only the thread safe version (php_pdo_sqlsrv_7_ts.dll , php_sqlsrv_7_ts.dll)
3.And edit the php.ini file add this extension to your php.ini file and restart and check
The extension file from Github MSPHPSQL releases did not work for me and gave me the same predicament with the OP. I went to this Microsoft article which gave me the driver (extension) for MSSQL Server, go ahead and install it on a directory you can easily find, in my case I saved it in my c:\mssql-driver then inside get the extension (DLL) file that fits your OS and PHP version, in my case since I am using PHP 7.2.x and x64 Windows I picked the following file and put it in my PHP extension directory c:\xampp\php\ext:
php_pdo_sqlsrv_72_ts_x64.dll
php_sqlsrv_72_ts_x64.dll
and in my php.ini located in c:\xampp\php\php.ini defined it under the Dynamic Extensions section:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
...
extension=curl
extension=php_pdo_sqlsrv_72_ts_x64.dll
extension=php_sqlsrv_72_ts_x64.dll
...
delete the "php_" on "php_sqlsrv_7_nts". just write "sqlsrv_7_nts"

Xul.dll missing dependencies after upgrade from Xulrunner and Gecko 14 to 33 due to Xpcom.dll conflict

I'm using Xulrunner and GeckoFX in a vb application (version 33.0-0.1 for both), and when debugging the application, the line
Gecko.Xpcom.Initialize(System.IO.Directory.GetCurrentDirectory() & "\xulrunner")
throws the exception:
Unable to load DLL 'xul': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Note that regardless of how I call the Initialize() function, the exact same exception comes up. I've tried:
Gecko.Xpcom.Initialize()
Gecko.Xpcom.Initialize(System.IO.Directory.GetCurrentDirectory() & "\xulrunner")
Gecko.Xpcom.Initialize(System.IO.Directory.GetCurrentDirectory() & "\bin\xulrunner")
Gecko.Xpcom.Initialize("C:\full path here\xulrunner")
This question Unable to load DLL (Module could not be found HRESULT: 0x8007007E) led me to use Dependency walker to check the dll.
Checking the dll showed that I was "missing" a slew of other things, as shown below:
That in turn led me to Win 7, 64 bit, dll problems, which also didn't help. While DW does show some of the same missing DLLs, it's also showing other ones that aren't listed in that question.
Of the offered solutions in that question, I've tried:
reinstalling the VS Redistributable Package
running 'sfc /scannow'
I've noticed in the aforementioned question that some people are saying it's an issue with OCX files instead of the DLL, but I'm not sure how to even start on that end. I couldn't find any OCX files in the project directory.
I realize that the problem may also lie in how I implemented GeckoFX and Xulrunner. Previously, this application was working using SkyboundGecko, GeckoFX, and Xulrunner. It seems that the previous developer working on this application followed this tutorial (or something very similar) using version 14 of GeckoFX and Xulrunner. However, this recently started causing problems for some customers using the application, as there was an Xpcom.dll conflict with a different application they were using. This issue only applies to those customers which had application X (I don't remember the name) installed on their computer. Other computers did not have this issue.
A bit of research has led me to believe that more current versions of GeckoFX and Xulrunner no longer require XPCom.dll, which means that an upgrade should in theory resolve this issue.
Thus, I started (loosely) following this tutorial in order to upgrade Gecko and Xulrunner. I removed the previous reference to the Skybound.Gecko.dll, and replaced Xulrunner with a newer version. I also downloaded and extracted the GeckoFX DLLs and files. My Bin now looks like this:
I added the reference to Gecko back to the project, and changed any references of Skybound.Gecko.xxxx to Gecko.xxxx. (Perhaps this tells you something that I don't know/haven't realized, since the tutorials I've seen never use Gecko.xxx - the function calls, for example, are Xpcom.Initialize() instead of Gecko.Xpcom.Initialize())
I'm running Windows 8 on Windows Server 2012 R2 Standard, 64 bit OS.
Is there another way to avoid the Xpcom.dll conflict, and if not, how do I resolve this issue?
If any other information is required, comment and I'll try my best to provide it.
In my case this error is caused because of I initialised xulrunner in Form1_Load function. I resolved it by initialising xulrunner in public Form1() function.
Try to initialise xulrunner as shown below,
public Form1()
{
InitializeComponent();
Gecko.Xpcom.Initialize(#"C:\Users\PAVILION\Documents\visual studio 2010\Projects\SiteFilterAutomation\SiteFilterAutomation\bin\Debug\xulrunner\");
}
private void Form1_Load(object sender, EventArgs e)
{
geckoWebBrowser1.Navigate("www.google.com");
}

Error loading javascript after installing Umbraco 4.7.1

I'm working on an umbraco 4.7.0 project and I have upgrated from 4.7.0 to 4.7.1
It's worked like a charm in my localhost but I have a problem after installing it on the staging server :
When I connect to the backend, I have the javascript error : "Jquery(xx).mask(...) : function does not exist" and any key press execute the umbraco Save function.
The jquery mask plugin is used in umbraco 4.7.1 to add a date mask to the publish date in the property tab.
The Jquery mask plugin is new in Umbraco 4.7.1 and is being included by "DateTimePicker.cs" with [ClientDependency(ClientDependencyType.Javascript, "MaskedInput/jquery.maskedinput-1.3.min.js", "UmbracoClient")]
See : https://hg01.codeplex.com/umbraco/rev/d2304aa897d4
However, even if I delete on the Staging server the bin,umbraco and umbraco-client folders and replace them with the ones from my local computer (where it works) the bug is still here.
But if I change
< compilation defaultLanguage="c#" debug="false" batch="false" targetFramework="4.0">
to
< compilation defaultLanguage="c#" debug="true" batch="false"targetFramework="4.0">
in the web.config THEN it works...
Does someone understand what happened ? How can I make it works with compilation debug=true ??
Thank you very much
Fabrice
As nobody answered this question, I asked on the umbraco forum here :
http://our.umbraco.org/forum/getting-started/installing-umbraco/25196-Error-loading-javascript-after-installing-Umbraco-471
The answer is :
"it's the outdated client dependency cache to blame (when you set debug="true" in your web.config this cache is turned off by design). Try simply to clean the contents of the client dependency cache folder (by default it's App_Data/TEMP/ClientDependency)."