ILMerge 和 MSBuild - 合并的 EXE 给出运行时错误
将 ILMerge 添加到我的构建后任务并制定命令行后,我成功获得了合并程序 MyMerged.exe
但当我运行它时,我收到异常
Unhandled Exception: System.TypeLoadException: 无法从程序集“mymerged,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”加载类型“Microsoft.Build.Utilities.TaskItem”,因为方法“.ctor”没有实现(无 RVA)。 at MyProgram.Program.Main(String[] args)
这是 ILMerge 中不处理没有构造函数的情况的错误,还是 TaskItem 中没有构造函数的错误。
谢谢
After adding ILMerge to my post build tasks and working out the commandline, I sucessfully get a merged program MyMerged.exe
But when I run it, I get an exception
Unhandled Exception: System.TypeLoadException:
Could not load type 'Microsoft.Build.Utilities.TaskItem' from assembly 'mymerged, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the method '.ctor' has no implementation (no RVA).
at MyProgram.Program.Main(String[] args)
Is this a bug in ILMerge not handling a situation where there is no constructor, or a bug in TaskItem for not having one.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 ILMerge 命令行上包含
Microsoft.Build.Utilities.dll
,以便将其合并到程序集中并找到。如果定义了重复类型并使用
/allowDup
命令行开关,ILMerge 将重命名重复类型,这也可能导致“无法加载类型...”错误和运行时的意外行为,尤其是当使用反射时。Include
Microsoft.Build.Utilities.dll
on the ILMerge command line so that it will get merged in with your assembly and found.If you have duplicate types defined and use the
/allowDup
command line switch, ILMerge will rename the duplicate types and this may also cause "Could not load type ..." errors and unexpected behavior during runtime, especially when reflection is being used.