代码之家  ›  专栏  ›  技术社区  ›  Owen Blacker Aditya

无法加载文件或程序集的Magick。NET-x86。DLL”或其依赖项之一。找不到指定的模块

  •  2
  • Owen Blacker Aditya  · 技术社区  · 7 年前

    我看过票了 “Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies” by Harsh Gupta

    我有一个web应用程序,包括ImageMagick,它刚刚安装在一个新的Windows Server 2012实例上(我们正在从Windows Server 2008 R2实例迁移到该实例)。该应用程序在Server 2008和本地运行正常,但在Server 2012上运行不正常。

    我在升级Magick后重建了该项目。Net从6.8.7.502到7.0.7.300,希望 .Net Standard / .Net Core support mentioned in the Readme in their accepted answer .

    模块:
    通知:
    无扩展URLHandler-Integrated-4.0
    0x00000000
    [修订]

    登录方法: 尚未确定
    登录用户: 尚未确定

    Event code: 3008 
    Event message: A configuration error has occurred. 
    Event time: 9/20/2017 6:20:40 PM 
    Event time (UTC): 9/20/2017 6:20:40 PM 
    Event ID: 4775ecdb4601401ca30aa057f77ae78a 
    Event sequence: 1 
    Event occurrence: 1 
    Event detail code: 0 
    
    Application information: 
        Application domain: [redacted]
        Trust level: Full 
        Application Virtual Path: / 
        Application Path: [redacted]
        Machine name: [redacted]
    
    Process information: 
        Process ID: 5096 
        Process name: w3wp.exe 
        Account name: IIS APPPOOL\[redacted]
    
    Exception information: 
        Exception type: ConfigurationErrorsException 
        Exception message: Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found.
       at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
       at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
       at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
       at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
       at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
       at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
       at System.Web.Compilation.BuildManager.ExecutePreAppStart()
       at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
    
    Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found.
       at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
       at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.Load(String assemblyString)
       at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
    
    
    
    Request information: 
        Request URL: [redacted] 
        Request path: / 
        User host address: [redacted]
        User:  
        Is authenticated: False 
        Authentication Type:  
        Thread account name: IIS APPPOOL\[redacted]
    
    Thread information: 
        Thread ID: 8 
        Thread account name: IIS APPPOOL\[redacted]
        Is impersonating: False 
        Stack trace:    at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
       at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
       at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
       at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
       at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
       at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
       at System.Web.Compilation.BuildManager.ExecutePreAppStart()
       at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
    
    
    Custom event details: 
    

    在webroot中查找 bin 文件夹确实包含Magick。NET-x86。dll(以及Magick.NET-Q16-x86.dll和Magick.NET-Q16-x86.Native.dll),以及 IIS_IUSRs 组对这些DLL(以及所有其他DLL)具有读取权限。

    启用32位应用程序 设置为 . 更改应用程序池的 集成的 经典 也没有效果。然而,我确实注意到,AppPool的应用程序数量被列为零(尽管网站的“高级设置”对话框显示了正确的AppPool名称): Screenshot of AppPools

    我完全不知所措,现在我们在迁移此应用程序方面落后于计划,因此我们将非常感谢您的建议。

    谢谢

    编辑以添加: #107 on Github .

    3 回复  |  直到 7 年前
        1
  •  2
  •   Owen Blacker Aditya    7 年前

    我没有答案,但有一些关于故障排除的想法,尽管你可能尝试过这些。

    1. 您使用的是apppool I'd,这是最好的,但如果更改为网络服务帐户有助于解决权限问题的话。
    2. 您是否比较了新旧服务器上安装的Windows功能?只是想知道它是否需要WCF。
    3. 基本的aspx页面可以工作吗?或者配置是否也破坏了这些页面。

    也许你已经尝试了所有这些,但希望它能帮助你找到另一个方向,即使它不能直接帮助你。

        2
  •  1
  •   Cy Rossignol Albert    7 年前

    尝试使用 Global Assembly Cache Tool ( 加库蒂尔。exe文件 )要向GAC发布缺失的程序集,请执行以下操作:

    gacutil.exe /i Magick.NET-x86.dll /f
    gacutil.exe /i Magick.NET-Q16-x86.dll /f 
    gacutil.exe /i Magick.NET-Q16-x86.Native.dll /f
    

    这个NET运行时扫描中的程序集 GAC 当它无法在本地路径中定位项目引用的程序集时。我们通常将GAC用于多个应用程序共享的程序集,但我们可以尝试这种方法进行故障排除。

    如果相关应用程序在将这些程序集发布到GAC后成功运行,则使用它们的项目中的程序集引用属性可能存在问题。

    测试后,我们可以删除我们从GAC中添加的程序集:

    gacutil.exe /u Magick.NET-x86 
    ...
    

    加库蒂尔。exe文件

    [Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") > $null
    [System.EnterpriseServices.Internal.Publish] $publisher = new-object System.EnterpriseServices.Internal.Publish
    $publisher.GacInstall('Path\To\Magick.NET-x86.dll')
    

        3
  •  1
  •   Owen Blacker Aditya    7 年前

    In a separate conversation on Github 随着ImageMagick的创建,我们最终检查了DLL的版本号,这使我们意识到了这一点以及预期的文件 Magick.NET-Q16-x86.dll Magick.NET-Q16-x86-Native.dll 两种版本 7.0.7.300 Magick.NET-x86.dll 6.8.7.502 .

    引用 Dirk Lemstra

    马奇克。NET-x86。dll 文件是不应该存在的旧文件。您可以删除该文件并检查是否解决了您的问题吗?很抱歉,我没有更早地注意到这一点。

    您不再需要安装C++redistributable。必要的库是静态链接的,这意味着您不再需要安装它。

    删除多余的文件解决了这个问题。