C# - How to embed DLL into the project?

10,824

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

Share:
10,824
avi12
Author by

avi12

I'm a software developer in my free time Usually programming in JavaScript My website: avi12.com

Updated on June 26, 2022

Comments

  • avi12
    avi12 almost 2 years

    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.

    • Broots Waymb
      Broots Waymb almost 7 years
      Why not just have the referenced dlls copy to the output folder on build?
    • Kdawg
      Kdawg almost 7 years
      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.
    • avi12
      avi12 almost 7 years
      @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
    avi12 almost 7 years
    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
    avi12 almost 7 years
    Didn't work - I tried executing the command in the directory where all the 3 files are, but Windows Powershell returned an error. i.imgur.com/0JyOa6j.png
  • avi12
    avi12 almost 7 years
    I even followed up the following tutorial and it didn't work for some reason: youtube.com/watch?v=a_r3tQ06xpE
  • Code Doggo
    Code Doggo over 4 years
    @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.