2

I'm looking to embed a DLL into the EXE of my WPF application so that I effectively only have 1 file to distribute, i.e. the .EXE. All of this stuff is completely over my head but I've followed the steps outlined in http://richarddingwall.name/2009/05/14/wpf-how-to-combine-mutliple-assemblies-into-a-single-exe/ but I still can't get this to work. Any ideas or help on this? As long as the DLL is in the same folder as EXE it works but if I remove the DLL, it will fail. However, I don't want the DLL to be present at all but rather embedded within the EXE. I've searched other posts here which recommend this solution but my problem is that everything compiles fine, it's just that it doesn't work and I don't know how to go about fixing it.

1) I have added the DLL in question as a resource to the project and set its Build Action to Embedded Resource

2) The code outlined in the above link, I've added to the App.xaml.cs file as well as using System.Reflection & System.IO

Is there anything esle I should be doing to get this to work?

Thanks

Shav

shane hickey
  • 21
  • 1
  • 3
  • 1
    possible duplicate of [Merging dlls into a single .exe with wpf](http://stackoverflow.com/questions/1025843/merging-dlls-into-a-single-exe-with-wpf) – Jonathon Reinhart Feb 18 '13 at 16:04
  • Hi Jonathon, I tried using NETz but couldn't get it to work. Some of the others you have to pay for. That's why I posted the question to see if there was a way to troubleshoot/fix the method I outlined. – shane hickey Feb 18 '13 at 16:38

2 Answers2

1

You could use ILMerge. We use it all the time to merge dll's into executable's and into other libraries.

Here's how someone else used ILMerge to accomplish this, so this could be considered a duplicate question.

Community
  • 1
  • 1
Seth Moore
  • 3,575
  • 2
  • 23
  • 33
1

If you are using Visual Studio w/Nuget, you can simply set your needed reference to 'copy local = true' and install Fody.Costura.

You can refine things a bit using a simple xml file, per the documentation provided on the project page (as well as tidy-up your build directory if desired).

Handprint
  • 444
  • 2
  • 4
  • 13