Updated date:

How To Develop a Standalone (EXE) C# Application


Most Microsoft .Net applications require a setup program (msi) to allow a user to install the application on a host computer. However there are times when you might need to package a C# application as a standalone exe. Meaning, you simply copy the executable to the host computer and it contains it needs to run.

To create an standalone C# application is very simple. The magic is in the compilation of the application, otherwise the rest of the application is like any other. Write your application as you would any other C# application. Standalone applications are best suited for command line (shell) applications, or desktop applications.

Here are the steps to create a standalone executable application that doesn’t require any installation or setup programs.

When you install Visual Studio, a set of utilities are installed along with the Microsoft SDK. One of these tools is the Visual Studio Command-Line Shell. You will find it in the Visual Studio folder from the Start menu under Tools.

1- Launch the Visual Studio Command Prompt (2010). You will find it under the Visual Studio Tools subfolder.

2-At the prompt enter the following commands:
a) csc (this is the C# compiler)

b) /out applicationname.exe (this flag specifies the name of the executable)

c) /reference “path and name of reference” (list the dlls that your application will needand these dlls will be packaged with the exe. Make sure to enclose the path andfilenames in double quotes if there are spaces in the path)

d) List the full path and filename of each C# file in the application

e) List full path and filename of any other file that is required for the application

Here is a sample script:

csc /out:MyCSharpApplication.exe /reference:"C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Excel.dll" C:\Users\klanguedoc\Documents\Visual Studio 2010\Projects\ProjectStandalone\ProjectStandalone\Program.cs C:\Users\klanguedoc\Documents\Visual Studio 2010\Projects\ProjectStandalone\ProjectStandalone\UpdateExcel.cs

This will compile a standalone executable. Of course you can create a batch and just run the batch file from the command prompt. Of you still to have the .Net framework installed on the host computer.

In Summary
Creating standalone applications is very easy and come in handy for different types of host devices or computers. These are also good for distributed applications which reduces complicated setup scripts.


Kevin Languedoc (author) from Canada on March 02, 2020:

are you getting an error message. Can you share

Nayeem Akhtar

Add them with their path on the build string


You need the .Net framework

d on February 19, 2020:

it doesn't work

Nayeem Akhtar on March 29, 2017:

if the application contains some external dll in a folder then how i can add it in the Standalone (EXE).

Kevin Languedoc (author) from Canada on August 12, 2014:

yes it should but you have to include the framework in the EXE. Get the re-distributable from the msdn site and add the dll reference to the inputs.

Vinix on August 11, 2014:

Will this work on machines without any version of .NET Framework?