突然我的网站没有加载,并给我下面的错误。我正在Windows 10家庭版上运行VS2017与. NET Framework 4. 7. 1。
[BadImageFormatException: Cannot load a reference assembly for execution.]
[BadImageFormatException: Could not load file or assembly 'System.IO.Compression.ZipFile' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +225
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
System.Reflection.Assembly.Load(String assemblyString) +34
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48
[ConfigurationErrorsException: Could not load file or assembly 'System.IO.Compression.ZipFile' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +729
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +247
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +157
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +321
System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734
[HttpException (0x80004005): Could not load file or assembly 'System.IO.Compression.ZipFile' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +708
有什么建议吗?
7条答案
按热度按时间xytpbqjk1#
对我有效的是删除我的Web应用程序下的bin和obj目录,然后重新构建。
3lxsmp7m2#
There's a known issue with .NET Framework 4.7.1 in this regard。应该在4.7.2中排序,但与此同时,您可以做些什么呢?
这个问题与序列化程序集有关,您可以选择将其设置为生成或不生成为构建的一部分(rclick project -〉Properties -〉Build选项卡-〉参见底部的“生成序列化程序集”)。
对我来说有效的--我在这里站在其他人的肩膀上--是确保将此设置设置为“自动”。执行完整的“干净解决方案”,此外,如果偏执狂,如果在解决方案根文件夹中运行此PowerShell代码段,将非常方便:
第一个月
接下来,将以下目标添加到csproj(就在封闭的
<Project>
标记内:如果仍然没有结果,请将“生成序列化程序集”显式设置为“开”以强制生成,然后重新生成并运行。
icomxhvb3#
今天我安装了Acumatica 2018 R1,遇到了这个问题。从bin文件夹中删除System.IO.Compression.ZipFile修复了这个问题。
eagi6jfj4#
我也多次遇到这个问题,这个错误可能是由引用或加载DLL的问题在您的bin文件夹中引起的。只需删除。bin文件夹并重建您的应用程序它会工作。
编程愉快。
tvz2xvvm5#
我对这个错误做了些调查
从错误中我们可以看出,当我们在Aspnetcore项目中引用基于SOAP的项目时,我们不能直接使用它们,这是由于Aspnetcore平台的实现。
它可以使用reflection加载。但是,它允许我们动态地使用内部类型。Aspnetcore的后续版本可能会发布对许可的soap汇编等的支持。
删除bin文件夹等是dll版本不同时的一种解决方案,如X86或64等。真实的的问题是SOAP协议、WebSocket、Proxy等的实现。它们不能直接用于Aspnetcore项目。github中有patch项目用于此
vuktfyat6#
删除所有nbin文件夹/obj文件夹/clean/rebuild后:什么都不会起作用。2错误信息清楚地告诉你有问题的程序集。3转到你的web.config文件并找到那个程序集。4删除它并重新引用它
fumotvh37#
我在从4.6.2升级到4.8时遇到了这个问题。
修复:
1.从web.config中删除程序集重定向
1.重建项目
1.双击vs中的程序集绑定警告以重新生成必要的重定向
1.无警告重建