6

I tried to use ILMerge on my WPF-based project (VS2010, Net4.0) but I couldn't make the merged executable to run. So I created two very simply projects

  • just a console application which prints out hello world
  • wpf application which shows window with hello world label

After compiling each project I get single executable file (so merging, does not really merge anything, it is just for test). Each executable works of course.

Then I "merge" each executable this way:

"C:\Program Files\Microsoft\ILMerge\ilmerge" 
    /targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319 
    /lib:c:\Windows\Microsoft.NET\Framework\v4.0.30319\wpf 
    /out:Merged.exe MyApplication.exe

(I made the call multiline just for SO readability). Ok, now console application is merged and runs as fine as before, the wpf application is merged without any errors but I cannot run it. I mean, I type

Merged.exe

Taskbar blinks, but nothing shows up -- no window, no error, nothing.

So how should I merge WPF app?

greenoldman
  • 16,895
  • 26
  • 119
  • 185
  • 1
    You can treat assemblies as ressources, see my answer [here][1]. [1]: http://stackoverflow.com/questions/1025843/merging-dlls-into-a-single-exe-with-wpf/7025702#7025702 – Matthieu Aug 11 '11 at 12:19
  • Possible duplicate of [Merging dlls into a single .exe with wpf](https://stackoverflow.com/questions/1025843/merging-dlls-into-a-single-exe-with-wpf) – StayOnTarget Jul 05 '18 at 11:27

2 Answers2

4

From what I know (and have experienced) ilmerge does not work correctly with WPF assemblies that have xaml resources embedded.

See this question for some possible solutions/alternatives

Community
  • 1
  • 1
saret
  • 2,217
  • 13
  • 12
  • Thank you, it seems merging assemblies comes at cost of nearly $1000 :-( – greenoldman Aug 17 '10 at 08:41
  • Yeah, it's a bit prohibitive - not sure can justify the cost myself to the company. What I ended up doing was merging all the assemblies except the WPF exe one – saret Aug 17 '10 at 09:07
  • I have to admit though that the general attitude towards solving problems (SmartAssembly) is outstanding. However 10% of the price for me would be a stretch. I have definitive word from Mike Barnett (author of ILMerge) -- it is not capable of merging WPF apps. Period. So I probably end up with your solution. – greenoldman Aug 18 '10 at 04:46
2

If I understand correctly, you want to embedded all assemblies into one exe.

There is an amazing NuGet package called Costura.Fody. Merging assemblies could not be easier!

If you need to merge Resource DLLs, you are in luck! There is another NuGet that extends Costura.Fody called Resource.Embedder!

Victor V.
  • 36
  • 3