1

I've never done this before, because I've never needed to until now, but I need to build my windows forms application to a standalone executable. I'm aware of both Build and Publish options within Visual Studio however none do what I need. Build doesn't allow you to move the executable it makes, and Publish makes a setup to install on the computer.

My goal is for the application to open without installation.

In the /bin/Debug/ directory made by the Build option, I have an executable, four dlls required, two .pdb file, and few other standard files (.manifest, .config, etc.). I was hoping to get any requirements built inside the executable.

How do I do this? All my searching has taken me to bunch of tutorials on how to make applications from scratch and how to use the csc.exe console command.

5
  • 1
    What do you mean by "Build doesn't allow you to move the executable it makes"? After you've built the application you should be able to copy the contents of the Debug/Release folder and run the executable (almost) anywhere. Commented Mar 31, 2016 at 12:59
  • 1
    I'm hesitant to cast a close vote, since the C# tag means my vote alone will close this one. But there is an older question here asking the same thing: stackoverflow.com/questions/126611/… It's possible there are newer answers, though. Commented Mar 31, 2016 at 12:59
  • @bwegs I'm sure if I moved all the files there together it will work, but I only want to move the executable. I tried moving it to another harddrive but it didn't even open. Commented Mar 31, 2016 at 13:00
  • @David I was obviously searching for the wrong stuff. I was searching for about an hour today and countless times in the past and never considered a merge would be involved so I didn't try searching for that. Commented Mar 31, 2016 at 13:02
  • 2
    Possible duplicate of Embedding DLLs in a compiled executable Commented Mar 31, 2016 at 13:41

2 Answers 2

1

You can merge the separate assemblies to make it one single executable.

There is a tool called ILMerge that is capable of doing that for you. Another method is described in this post, which also works for WPF.

Sign up to request clarification or add additional context in comments.

Comments

1

What you want is to embed the .DLLs in the .exe file so you can move it freely and only need the .exe , you just didn't search for the right thing, here is what you are looking for :

It is possible to merge .NET executables with libraries. There are multiple tools available to get the job done:

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly.

Mono mkbundle, packages an exe and all assemblies with libmono into a single binary package.

IL-Repack is a FLOSS alterantive to ILMerge, with some additional features.

See : Embedding DLLs in a compiled executable

this is indeed a duplicate but i don't have the reputation to mark it as so.

9 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
@drneel well i did answer by saying what he wants to do and by saying it IS a duplicate just written in different words ( which is why he couldn't find the existing post ) , I don't see my post as being Low Quality since i can't comment and wanted to answer him since i knew what he was looking for, even if it is a duplicate.
You can flag posts as duplicate at 15 rep; stackoverflow.com/help/privileges . Use the flag option under the question and it will prompt you for a reason and if you choose duplicate it will as you for a link. It will then add that as a comment to the question.
@drneel the duplicate option is not there for me ( i tried before answering and tried again right now, the only options i have are : Spam, Rude or Abusive , Very low quality, in need of moderators. But thanks, i will rewrite the answers and give the link to the duplicated question now.
@PatrickHofman I've been reproached that i needed to answer the Question even if it was duplicated since i can't make a duplication flag, looks like you can't please everyone.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.