构建错误“试图加载格式错误的程序集".将Net Framework 4.5.2升级到4.7.1之后 [英] Build error "An attempt was made to load an assembly with an incorrect format " after upgrade net framework 4.5.2 to 4.7.1

查看:74
本文介绍了构建错误“试图加载格式错误的程序集".将Net Framework 4.5.2升级到4.7.1之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试更新程序的框架.我们目前在4.5.2版中拥有该软件,并且希望将其更新到4.7.1版中.

We are trying to update the framework of our program. We currently have it in version 4.5.2 and we want to update it to version 4.7.1

我们已经更改了解决方案的所有csproj,并且当我们在调试中进行编译时,应用程序将正确编译并正常工作.但是,当我们在发行版中执行此操作时,它将失败并显示以下错误:

We have changed all the csproj of the solution, and when we compile in debug, the application compiles and works correctly. But when we do it in release, it fails us with the following error:

An attempt was made to load an assembly with an incorrect format: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades\System.IO.Compression.ZipFile.dll

我们真的不知道出什么问题了,有人知道这可能是什么吗?

We don't really know what's wrong, does anyone know what it could be?

非常感谢.

推荐答案

更新:正如Josh在下面建议的那样,由于4.7.2可用了,请升级到该.NET版本以最佳解决此问题.

UPDATE: As Josh suggests below, now that 4.7.2 is available, upgrade to that .NET version for the best resolution of this problem.

如果坚持使用4.7.1:这可能无法解决问题的根源,但是如果您暂时想解决此问题,请找到有问题的项目并编辑其设置(点击项目属性",然后点击构建"标签.)

If stuck with 4.7.1: This probably isn't addressing the root of the problem, but if you want to get over this for the moment, then find the offending project and edit its settings (rclick project, 'Properties', then 'Build' tab.)

在发布模式下,将生成序列化程序集"设置为关闭".

Set 'Generate serialization assemblies' to 'Off' for Release mode.

如果仍然存在问题,请尝试将以下< Target> s添加到您的.csproj文件中(例如,朝底部,恰好在封闭的</Project> 根标签:

If it still complains, try adding the following <Target>s to your .csproj file (e.g. towards the bottom, just inside the enclosing </Project> root tag:

<Target Name="RemoveDesignTimeFacadesBeforeSGen" BeforeTargets="GenerateSerializationAssemblies">
    <ItemGroup>
      <ReferencePath Remove="@(_DesignTimeFacadeAssemblies_Names->'%(OriginalIdentity)')" />
    </ItemGroup>
    <Message Importance="normal" Text="Removing DesignTimeFacades from ReferencePath before running SGen." />
  </Target>
  <Target Name="ReAddDesignTimeFacadesBeforeSGen" AfterTargets="GenerateSerializationAssemblies">
    <ItemGroup>
      <ReferencePath Include="@(_DesignTimeFacadeAssemblies_Names->'%(OriginalIdentity)')" />
    </ItemGroup>
    <Message Importance="normal" Text="Adding back DesignTimeFacades from ReferencePath now that SGen has run." />
  </Target>

这篇关于构建错误“试图加载格式错误的程序集".将Net Framework 4.5.2升级到4.7.1之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆