ILMerge and MSBuild - merged EXE is giving runtime error
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.
精彩评论