c# - 升级到 .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
解决方案
推荐阅读
- python - Pandas 方括号链接与单括号中的双索引
- python - 如何在 Python 脚本中通过 CMDline 传递参数
- python - 如何在 Chatterbot 烧瓶应用程序中发送可点击的链接和邮件
- elasticsearch - 带有数字标记的弹性搜索映射
- .net - SQL Server 忽略连接字符串参数
- scala - 发现 scala 类型不匹配 Future[A] 预期 Future[B]
- sql - SQL 计数未完成的行
- r - 如何在 R 中沿着距离矩阵绘制树状图?
- java - 在 void 异步方法之外获取字符串的值?
- html - Rmarkdown 到 Windows 上的 html:DT::datatable 未呈现(怀疑 pandoc 问题)