【问题标题】:Runtime Version of ILMerge'd assembly is v4.0.20926; expected version is v4.0.30319ILMerge 程序集的运行时版本是 v4.0.20926;预期版本为 v4.0.30319
【发布时间】:2010-05-12 15:10:22
【问题描述】:

这就是我的 .csproj AfterBuild 的样子:

  <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
    <Exec Command="&quot;..\Tools\ILMerge\ILMerge.exe&quot; /internalize /ndebug /out:@(MainAssembly) /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 &quot;@(IntermediateAssembly)&quot; @(ReferenceCopyLocalPaths->'&quot;%(FullPath)&quot;', ' ')" Condition=" '$(TargetFrameworkVersion)' == 'v4.0'" />
  </Target>

我正在运行 64 位 Windows。我尝试将 .NET Framework 从 ...\Microsoft.NET\Framework\... 更改为 ...\Microsoft.NET\Framework64\...,但没有帮助。

我还在 ILMerge 目录中创建了 ILMerge.exe.config:

<?xml version ="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
    </startup>
</configuration>

为什么 ILMerge 不生成 4.0.30319 程序集?

【问题讨论】:

  • 你使用的是什么版本的 ilmerge?
  • 我尝试了 5 月 26 日 2.10.0526 发布的更新版本(因为有人问了这个问题),但我仍然遇到同样的问题。
  • 这似乎是 ILMerge 中的一个错误,它会生成 .Net 4.0 Beta2 的运行时版本。我知道这确实无济于事,但您可以联系 Microsoft 的 Mike Barnett(他的电子邮件位于 ILMerge 下载页面)抱歉
  • 我几天前就此事联系过他,所以他知道了。

标签: .net ilmerge


【解决方案1】:

编辑:此问题已在 2011 年 5 月 2 日发布的 v2.11.0502 中得到修复,因此我删除了自定义版本的下载链接。

我已修复 ILMerge.exe (v2.10.0526),以便它设置目标运行时版本 v4.0.30319 而不是 v4.0.20926。您可以从此链接下载 ILMerge.exe 的固定版本:

(链接已删除,下载正式版here)

像往常一样用这个参数运行它

/targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319

并且输出程序集现在将针对 v4.0.30319。我用反射器检查过,没关系。让我知道你的结果。

请注意,您不需要使用 ILMerge.exe.config,我猜它是用于使用 .Net 4 框架运行 ILMerge.exe 本身,但这并不意味着它会强制 ILMerge.exe 生成 .净 4 个组件。输出程序集的目标框架版本仅由 /targetplatform 参数控制。

【讨论】:

  • 测试人员您好,谢谢!有机会我会试试看的。
  • 我将链接的文件复制下来,并且可以确认它确实将输出程序集正确设置为 v4.0.30319,而 MS 下载版本将其设置为 v4.0.20926。
【解决方案2】:

同样的问题!!

我使用 ILMerge 来定位 v4,无论有无 /targetplatform:v4 并得到相同的结果:.net 运行时版本定位具有更大的 .net v4 修订版(如反射器所述)。

让我开始挖掘的基本问题是与基于 Linq 和 Lambda 的代码中的(Cannot load type System.Func´2 Exception from )相关的错误。

如果我用依赖程序集的非合并版本替换合并版本,则不会引发异常。

【讨论】:

  • 这也是我第一次注意到问题的方式。
猜你喜欢
  • 2011-01-18
  • 1970-01-01
  • 2011-06-07
  • 1970-01-01
  • 2011-04-10
  • 2021-01-08
  • 2019-12-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多