4

I'm working on a project in Visual Studio where I need to embed 2 DLLs.
So far, I've been referencing those DLLs, but then I cannot use them without actually having the files in the same folder as my EXE.
Obviously, I want my users to only need the EXE to use them, without having to download the DLLs as well.
The thing I tried to far is following this tutorial: https://www.youtube.com/watch?v=lx2tSY4joDg
But this is only for one file and the tutorial sadly didn't work for me.

What can I do? Thanks!

EDIT: The project was built by Windows Forms Application.

avi12
  • 2,000
  • 5
  • 24
  • 41
  • Why not just have the referenced dlls copy to the output folder on build? – Broots Waymb Jul 17 '17 at 21:35
  • Out of curiosity, why not just supply the exe and the DLLs in a compressed archive format? Compressing them would save on bandwidth, and most users are familiar with how to unzip a file. A self-extracting archive would make it even easier. – Kdawg Jul 18 '17 at 01:44
  • @Kdawg In terms of size, my program's size isn't large at all. And in the archive thing, I don't want to let the users mess with extracting, but just keep everything simple, as the software meant to simplify a process in the computer. – avi12 Jul 18 '17 at 10:54

2 Answers2

2

As long as you aren't using .NET Core, it is really easy to do this now with Costura.Fody (As answered here).

Just add the nuget package like this, and it's basically turnkey from there! Install-Package Costura.Fody

Dusty
  • 3,946
  • 2
  • 27
  • 41
  • 1
    Didn't work - I tried executing the command in the directory where all the 3 files are, but Windows Powershell returned an error. http://i.imgur.com/0JyOa6j.png – avi12 Jul 17 '17 at 22:02
  • @avi12 You run this command within the NuGet console of say Visual Studio. From my understanding, you cannot run this command outside in say Powershell. – Code Doggo Oct 07 '19 at 21:56
0

You will need to use ILMerge

After you build with Visual Studio, you can merge the libraries like this:

ilmerge /target:winexe /out:MergedAssembly.exe VSBuiltAssembly.exe Lib1.dll Lib2.dll
ohmusama
  • 4,159
  • 5
  • 24
  • 44
  • Still didn't work for me. I'm probably doing something wrong. I put all three files in the same directory, executed the command, the folder was refreshed, but when testing it (I put the EXE in the Desktop) - didn't work. – avi12 Jul 17 '17 at 21:54
  • 1
    I even followed up the following tutorial and it didn't work for some reason: https://www.youtube.com/watch?v=a_r3tQ06xpE – avi12 Jul 17 '17 at 22:36