首页 > 解决方案 > 升级到 .NET 472 后出现 BadImageFormatException 错误

问题描述

从 .NET 461 升级到 472 之后,当我尝试运行我的项目时,我收到以下错误消息

我已经清理/重建了我的项目。我已经删除了所有文件夹,但没有bin运气obj

我需要使用 NuGet 做些什么或<dependantAssembly>从 web.config 文件中删除任何属性吗?

[BadImageFormatException:无法加载要执行的参考程序集。]

[BadImageFormatException:无法加载文件或程序集“System.IO.Compression”或其依赖项之一。不应加载引用程序集以供执行。它们只能在 Reflection-only loader 上下文中加载。(HRESULT 异常:0x80131058)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark 和 stackMark,IntPtr pPrivHostBinder,布尔 throwOnFileNotFound,布尔 forIntrospection,布尔suppressSecurityChecks)+0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblySecurityRef, Evidence assembly , RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean for Introspection) +21 System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective ) +38

[ConfigurationErrorsException:无法加载文件或程序集“System.IO.Compression”或其依赖项之一。不应加载引用程序集以供执行。它们只能在 Reflection-only loader 上下文中加载。(来自 HRESULT 的异常:0x80131058)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName,布尔 starDirective)+726
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+196 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +45
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +172
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +111
System.Web.Compilation.BuildManager.ExecutePreAppStart() +156
System.Web.Hosting。 HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +695

[HttpException(0x80004005):无法加载文件或程序集“System.IO.Compression”或其依赖项之一。不应加载引用程序集以供执行。它们只能在 Reflection-only loader 上下文中加载。(HRESULT 异常:0x80131058)] System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文)+659
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文)+89 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext 上下文)+188

标签: c#.netvisual-studio

解决方案


推荐阅读