0

I have created a backup console application (this is 32bit program running on .net 3.5 on windows 8 64bit) with these dlls:

Delimon.Win32.IO,

SevenZipSharp,

7z(native) dll I have tried to merge them with ilmerge but program still asks dlls( Delimon.Win32.IO not found ) while startup.

Then I tried second solution: add dll's to resources & handle AssemblyResolve event, still same problem.

Any clue what is problem?.

I dont want any commercial solution.

Keren Caelen
  • 1,466
  • 3
  • 17
  • 38
Ankush
  • 63
  • 9
  • Did you try merging the DLLs together, or did you merge the DLLs into an exe? At what point do you add the `AssemblyResolve` handler? – Jean Hominal Jul 12 '13 at 07:57
  • Try to embed your DLL as resource instead, like described here : http://stackoverflow.com/questions/3371583/serious-trouble-with-ilmerge-and-net-4-0 – Laughingman Jul 12 '13 at 08:02
  • I tried to merge dlls into exe & added Assembly resolve event to main() function of console app. – Ankush Jul 12 '13 at 08:02
  • You've actually got two questions here: "How do I use ILMerge to merge my DLLs?" and "What is wrong with my project with embedded resources?" You might want to either look up each one of those individually or maybe split this question into two. – Izzy Jul 12 '13 at 08:04
  • Found solution here: [Solution][1] [1]: http://www.danderson.me/posts/embedding-referenced-assemblies-as-an-embedded-resource-and-resolving-dependencies-at-runtime/ The only problem was in main() there should be only Assembly resolve handler code & not the code which depends on dll. So I just moved all dependent code in main to other function submain & called this from main. – Ankush Jul 12 '13 at 11:48

1 Answers1

2

I'd recommend using Costura.

https://github.com/Fody/Costura

Costura is avaliable on NuGet and is a simple solution for providing a custom AssemblyResolve system. It will take all your projects references and automatically add them at build time.

Also, if you have native or mixed-mode assemblies (like for example 7zip) then you'll need to provide Costura with a bit of configuration. Everything is covered in the readme.

Cameron MacFarland
  • 70,676
  • 20
  • 104
  • 133