开发者

ILMerge and MSBuild - merged EXE is giving runtime error

开发者 https://www.devze.com 2023-03-29 17:20 出处:网络
After adding ILMerge to my post build tasks and working out the commandline, I sucessfully get a merged program MyMerged.exe

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.开发者_StackOverflow中文版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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号