Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

C# - Create Windows Form Application Setup File in C#.Net

Oct 16, 2014
Introduction

Here I will explain how to create setup file for windows form application in visual studio 2008 in
c# with example. To create setup file windows application in c# we need to use setup and deployment section templates in visual studio.

Description:
  
In previous articles I explained constructors in c# with examples, difference between virtual, override, new keywords in c#,
Difference between sessionstate and viewstate, Highlight gridview rows on mouseover in jQuery and many articles relating to asp.net, c#,vb.net and JQuery. Now I will explain how to create setup file for windows form application in visual studio 2008 in c# with example.

Before we create setup file for windows form application first we will create one sample windows forms application

Go to File à project à select Windows Forms Application à Give name to your application à click OK like as shown below


Now in your page add Textbox and button controls and double click on your button and write the code like as shown below


private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text.Trim();
if(str!="")
{
MessageBox.Show("Thank You For Interest", "Success");
}
else
{
MessageBox.Show("Please Enter Name", "error");
}
}
Once you write the code run your application that will return the output like as shown below

Output

Now we have sample windows form application for this we will create setup file.

First close your application and again open visual studio and create new setup project by following below steps

Go to File à Project à Other Project Types à Select Setup and Deployment à Select Setup project like as shown in below image


It will open window like as shown below in which contains three folders those are Application Folder, User’s Desktop and Users’ Program Menu. These folders are the places where we want to copy our setup files during installation process. Now right click on Application folder and select Add à File like as shown below

Once we click on File it will open new window in that navigate to bin folder of your sample windows form application and select your application .exe file and click OK like as shown below

Once we add exe file now right click on your setup file and click on create shortcut to add that shortcut to User’s Desktop folder or User’s Program menu when you install the application

Now right click on your setup project like as shown below to change properties

In properties window click on Prerequisites button to add required changes like .NET framework, SQL Server Compact to setup file like as shown below

Once you done all the changes now right click on your setup project and click Build it will create setup file in your setup application folder like as shown below


Now open your setup files application folder and check it in debug folder it will contains setup files like as shown below 

Now click on your setup file to install it. If you click on setup file it will open window like as shown below

Now click Next Next in windows it will install your application like as shown below


Once installation completed it will create shortcut on desktop because we added a properties to create shortcut on desktop if you open it will be like this

I hope it helps you to create setup file for your windows form application.....

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

13 comments :

sanju said...

Very Nice. Explained it in very simple format. TY :)

Unknown said...
This comment has been removed by a blog administrator.
Anonymous said...

Can any one tell me difference between ASP.NET_SessionId and session.sessionid.

and also with default time out value


Anonymous said...

Very Nicely Explained. Thanks Suresh

Unknown said...

it's ok. But if i want to retrieve a file within the setup file to a particular folder within a drive, how can i solve?

Unknown said...

nuvv keka anayy....superb

Unknown said...

pls upload windows applications in c# ....for freshers

john said...

great tutorial

Unknown said...

i want to create a setup with table and store proc...so plz help me sir...

Thanks

Anonymous said...

how do i do same thingi vs 2012 with product key text box plz assist

Unknown said...

nice post thankyou verymuch it is useful to all of us i have small doubt please clarify tech support job is best or not pls rly to my questio

Unknown said...

Too helpful post in a simple format... Awesome post..

Anonymous said...

While make setup in c# how to include report rdlc in the exe?? Can anyone know

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.