Create GUI C# Application Without Opening Visual Studio IDE

No.of Views1635
Bookmarked1 times
Downloads 
Votes0
By  kirtan007   On  16 Feb 2010 00:02:48
Tag : CSharp , Windows Forms
Create GUI C# Application Without Opening Visual Studio IDE
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

Here is trick to Compile the C# Application Program without opening the Visual Studio
it is not recommanded but this is somthing you should know when you have only command line interface and want to create some handy utility.

In Article we are Creating Sample Program that Will Show Hello in MessageBox When We Click Button

Technologies:

.Net 2.0/3.5

Language:

C#
Prerequisite

1. .NET Framework 2.0/3.5
2. Visual Studio 2008/2005
3. Programatically Event Handling Knowledge   


Implementation


Fire up Note pad

And Write C# Program like below


{codecitation class="brush: csharp; gutter: true;" width="650px"}


//Declare Name Spaces
using System;
using System.Windows.Forms;

// Display Controls on Form Programatically

namespace TestGUI
{
class Test:Form
{
// Create Constuctor of Class

// Global Variables
public TextBox t1;
public Button b1;

Test()
{

//Suspend the layoutl logic
this.SuspendLayout();

//Set Properties of Button a
b1=  new Button();
b1.Location =new System.Drawing.Point(30,40);
b1.Text = "Click Me";

//Add handler to Button
b1.Click += new System.EventHandler(b1_Click);


//Set Properties of Text Box
t1 = new TextBox();
t1.Location  = new System.Drawing.Point(20,20);

//Add Conponents on form
this.Controls.Add(b1);
this.Controls.Add(t1);

//Give Form title
this.Text = "GUI Without VS";

//Resume the layout

this.ResumeLayout(false);

}

public void b1_Click(Object Sender,EventArgs e)
{
MessageBox.Show("Hello you Clicked Me");
}
//Now every thing is done Lets Build The Main method
public static void Main()
{
Application.Run(new Test());
}

}

}


{/codecitation}

Save the File With name GUITest.cs

and Then Open Cmd and change directory to C:\Program Files\Microsoft Visual Studio 8\VC\

by

cd  C:\Program Files\Microsoft Visual Studio 8\VC\

command

then enter the Command  to Compile the exe here target is Type of Out put we want and /out  is used to Create our output file

csc.exe /target:exe /out:c:\Users\
Kirtan\Desktop\GUITest.exe C:\Users\Kirtan\Desktop\GUiTest.cs

Conclusion

The Article Exlaines About how to compile program with csc.exe of Visual Studio .

Thank you

 
Sign Up to vote for this article
 
About Author
 
kirtan007
Occupation-
Company-
Member Type-Senior
Location-Not Provided
Joined date-02 Jul 2009
Home Page-http://kirtan.uni.cc
Blog Page-
He completed his Bachelor of Computer Application from Gujarat University 2009 .He is doing Master of Computer Application from Gujarat Technological University right now .. His area of Interests are Web Hacking , C# .net Windows form ,asp.net , WPF ,Silverlight ,SQL Server and Some PHP.
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top