Taritsyn / JavaScriptEngineSwitcher

JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines. This library allows you to quickly and easily switch to using of another JavaScript engine.
Apache License 2.0
439 stars 49 forks source link

Issues after updating BundleTransformer packages in ASP.NET MVC project #112

Closed Metinak47 closed 9 months ago

Metinak47 commented 9 months ago

Hi my friends After updating the BundleTransformer packages in my ASP.NET MVC project, I encountered a critical issue that is preventing the project from running successfully. Prior to the update, I was using BundleTransformer along with JavaScriptEngineSwitcher, and everything was working fine. However, after the update, the project fails to start, and I receive the following error:

Could not load file or assembly 'file:///D:\Project Path\bin\ClearScriptV8.win-x64.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

Troubleshooting Steps Taken: Updated BundleTransformer packages to the latest versions. Updated ClearScriptV8.win-x64.dll to version 7.4.4.0 as specified. Switched from JavaScriptEngineSwitcher.V8.Native.win-x64 to Microsoft.ClearScript.V8.Native.win-x64 as recommended. Despite the changes, the issue persists.

Package Versions Used: ClearScript.V8: 7.4.4.0 MsieJavaScriptEngine: 3.2.2.0 DartSassHost: 1.0.8.0 AutoprefixerHost: 1.1.10.0 BundleTransformer.Core: 1.10.0.0 JavaScriptEngineSwitcher.Core: 3.21.0.0 LibSassHost: 1.2.10.0 System.Text.Encodings.Web: 8.0.0.0 (updated during the process)

Additional Information: The update process for System.Text.Encodings.Web resulted in an error, but the package was successfully updated to version 8.0.0.0.

Request for Assistance: I kindly request assistance in resolving this issue and getting the project back to a stable state. Any guidance on further troubleshooting or specific package versions compatibility would be greatly appreciated.

Thank you for your time and support.

Daniel15 commented 9 months ago

Does the ClearScriptV8.win-x64.dll file exist in the bin directory?

Metinak47 commented 9 months ago

Yes, it is exist.

Taritsyn commented 9 months ago

Hello!

Starting from version 3.9.0, JavaScriptEngineSwitcher.V8 module is no longer responsible for deploying and loading the native assemblies (corresponding functionality is now implemented in the Microsoft.ClearScript.V8.* packages).

Unfortunately, modern versions of NuGet do not always work stable with .NET Framework projects and because of this, sometimes there are failures after installing packages. Therefore, I recommend you to perform a clean installation:

  1. Uninstall the following packages: JavaScriptEngineSwitcher.V8 and Microsoft.ClearScript.*.
  2. From the .csproj file, remove lines like these:
    <Import Project="..\packages\Microsoft.ClearScript.V8.Native.win-*\build\Microsoft.ClearScript.V8.Native.win-*.props" Condition="Exists('..\packages\Microsoft.ClearScript.V8.Native.win-*\build\Microsoft.ClearScript.V8.Native.win-*.props')" />
    <Error Condition="!Exists('..\packages\Microsoft.ClearScript.V8.Native.win-*\build\Microsoft.ClearScript.V8.Native.win-*.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ClearScript.V8.Native.win-*\build\Microsoft.ClearScript.V8.Native.win-*.props'))" />
  3. Remove the bin and obj directories.
  4. Restore a NuGet packages.
  5. Install the following packages: JavaScriptEngineSwitcher.V8 and Microsoft.ClearScript.V8.Native.win-x64.

… DartSassHost: 1.0.8.0 … LibSassHost: 1.2.10.0

If you are using the latest version of the BundleTransformer.SassAndScss module, then I recommend that you remove the LibSassHost packages (see the corresponding section of documentation).

Metinak47 commented 9 months ago

Thanks for your response.

I uninstalled every thing about BundleTransformer and JavaScriptEngineSwitcher from project. I installed again packages (last version) but I still got error:

Could not load file or assembly 'file:///D:\.Net Project\Project Pathbin\ClearScriptV8.win-x64.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

Taritsyn commented 9 months ago

Try to make a demo console application:

  1. Create a project based on the “Console App (.NET Framework)” template.
  2. Select a “.NET Framework 4.5” as target framework.
  3. Install the Microsoft.ClearScript.V8 and Microsoft.ClearScript.V8.Native.win-x64 packages.
  4. Replace a contents of the Program.cs file with code similar to this:
    
    using System;

using Microsoft.ClearScript.V8;

namespace TestClearScriptV8 { internal class Program { static void Main(string[] args) { using (var engine = new V8ScriptEngine()) { var result = (int)engine.Evaluate("2 * 2"); Console.WriteLine("Result: {0}", result); } } } }


 5. Launch the console application.
Metinak47 commented 9 months ago

I created a console application and that is works fine! But still I have error in asp.net mvc project (with .net framework 4.7.2)

Taritsyn commented 9 months ago

In unedited version of the previous message it is written:

I create a console application in net framework 4.7.1 and 4.7.2 (I don't have .net framwork 4.5) but I still got error.

Cannot load ClearScript V8 library. Load failure information for ClearScriptV8.win-x86.dll: D:\Sources\ConsoleApp3\bin\Debug\runtimes\win-x86\native\ClearScriptV8.win-x86.dll: The specified module could not be found D:\Sources\ConsoleApp3\bin\Debug\ClearScriptV8.win-x86.dll: The specified module could not be found'

After what changes did the console application start working?

Metinak47 commented 9 months ago

That was my mistake and application was x86 then I changed to x64 works fine. But my asp.net project is in x64.

Taritsyn commented 9 months ago

Try installing two packages at once into your web application: Microsoft.ClearScript.V8.Native.win-x86 and Microsoft.ClearScript.V8.Native.win-x64.

Taritsyn commented 9 months ago

If this error still occurs, then try to reproduce the error in the form of simplest demo web application and send me a link to it.

Metinak47 commented 9 months ago

I create a simple MVC application and used BundleTransformers. I found my problem. I used V8JsEngine before and that has error for v8-lib-cpp or ClearScript-X64.exe and not workes. I updated all of my packages to last version and used MsieJsEngine for AutoPrefixer jsEngine instead of V8JsEngine and resolved my problem.