【问题标题】:Cannot load assembly or dependencies with ClearScript.V8无法使用 ClearScript.V8 加载程序集或依赖项
【发布时间】:2017-06-27 21:16:34
【问题描述】:

我使用 ClearScript.V8 开始了一个项目。 我正在使用 C# 在 Windows 10 和 Visual Studio 2015 上进行开发。 Web 是 IISExpress,最终将在 Windows 2012 服务器上发布。 我使用 NuGet 添加了包 ClearScript.V8 (v5.4.9)。我总是从一开始就收到下面的错误,甚至还没有初始化 ClearScript(是的,它是法语,但应该很容易理解):

Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses Dependances。 Le module spécifié est introuvable.

描述 : Une exception non gérée s'est produite au moment de l'execution de la requête Web actuelle。 Contrôlez la trace de la 堆 pour plus d'informations sur l'erreur et son origine dans le code。

异常详情:System.IO.FileNotFoundException: Impossible de 充电器 le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses 依赖。 Le module spécifié est introuvable.

错误来源:

Une exception non gérée s'est produite lors de l'exécution de la 请求网络活动。 Les informations relatives à l'origin 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。模块规格 est introuvable。]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+152
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security、StackCrawlMark& stackMark、IntPtr pPrivHostBinder,布尔用于自省)+77
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security, StackCrawlMark& stackMark, Boolean forIntrospection) +21 System.Reflection.Assembly.Load(String 组装字符串)+28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances。乐模块 spécifié est introuvable.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName,布尔型 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(字符串 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, 异常 appDomainCreationException) +549

[HttpException (0x80004005): Impossible de Charger le fichier ou l'assembly 'ClearScriptV8-32.DLL' ou une de ses dépendances。乐模块 spécifié est introuvable.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文)+10044576 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文)+95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext 上下文)+254

版本信息:Microsoft .NET Framework 版本 :4.0.30319; ASP.NET 版本:4.7.2046.0

我按照https://microsoft.github.io/ClearScript/Details/Build.html(尤其是第 IV 节)的说明进行操作,因此我的 bin 中有文件 ClearScript.dll、ClearScriptV8-32.dll、ClearScriptV8-64.dll、v8-ia32.dll 和 v8-x64.dll文件夹。我的根文件夹中也有 ClearScriptV8-32.dll 和 ClearScriptV8-64.dll(复制到输出 = 不要复制)。

我错过了什么?

【问题讨论】:

    标签: c# .net v8 clearscript


    【解决方案1】:

    尝试将所有这些 DLL(ClearScriptV8-*.dll、v8-*.dll)放入根文件夹,并确保您没有有副本bin。如果您要部署到没有 Visual Studio 的机器上(或有 Visual Studio 但没有 C++ 支持),请安装适当版本的 Visual C++ Redistributable(它必须与用于构建 ClearScript 的编译器匹配)。

    【讨论】:

    • root 中的所有文件都存在同样的问题,bin 中没有副本。
    • 确保您将所有这些文件的Copy to Output Directory 设置为Do not copy。如果您在应用启动时(LoadAllAssembliesFromAppDomainBinDirectory 内)仍然发现问题,请发布另一个堆栈跟踪。
    • 这完全让我感到困惑。只是为了确保我使用 Visual Studio 2015 从头开始​​重新创建了一个新项目,添加了 ClearScript.V8 而没有其他任何内容,但仍然出现相同的错误。如果我移动或复制 DLL,我只是不明白它应该如何工作在某些时候,如果 bin 中没有副本并且我不复制到输出目录,您似乎建议网络不应该有任何指定的 dll .如果我在 x64 上运行,为什么它会尝试使用 -32.dll?为什么这个包应该简单明了却使用起来如此复杂?
    • 当我从 bin 中删除文件时,它们会在构建后重新出现。
    • 检查复制这些文件的自定义构建步骤;有时 NuGet 包会添加这些。而且,正如我所提到的,如果没有其他方法,您应该能够在 web.config 中明确排除这些文件。
    猜你喜欢
    • 1970-01-01
    • 2021-12-12
    • 2012-01-14
    • 1970-01-01
    相关资源
    最近更新 更多