Abstract: In this article, I am going to explain setup and deployment procedure in windows project by using visual studio.
To demonstrate this article I took small Merlin.acs [.acs=Agent character structured storage file] COM Component and teddy Bear Database Manips in my Windows Project. Finally I will give total roundtrip for Setting up and deployment of windows Project. I divided this article into two Parts.
In this part, I explained total development procedure in windows and C# by utilizing COM Components and Database Manipulations Using ms access.
Windows Setup and
Deployment
Abstract: In this article, I am going to
explain setup and deployment procedure in windows project by using visual
studio.
To demonstrate this
article I took small Merlin.acs [.acs=Agent
character structured storage file] COM Component and teddy Bear Database Manips in my Windows Project.
Finally I will give total roundtrip for Setting up and deployment of windows
Project. I divided this article into two Parts.
PART-1)
In this part, I explained total development procedure in windows and C# by
utilizing COM Components and Database Manipulations Using msaccess.
PART-2) In Second part, I
totally focused on Set Up and Deployment Procedure by using PART-1 developed
Code and Their dependencies.
PART-1:
Developing Windows Application Using C#
Here I developed three windows forms one is MDI FORM (ParentForm.cs)-which is
always visible until user explicitly Quits, Second One Is Login Form (Form1.cs)
with Merlin COM Component-which checks weather the user exits or not and finally
third form (ParentForm.cs) loads after Successful Login Credentials entered by
the user-which displays some data from the database.
Assume that, just
this is a Case study for our deployment activity like a small Mickey Mouse Type
of Project to understand the article effectively.
To do this project
–Open Visual Studio-File-New-Project-Visual C#-Windows Application-Name as your
choice.
ParentForm.cs[Design]
1)
Choose any Background
Image According To your Choice and assign property IsMDIContainer=true
2)
Place One Picture BOX
for Login Image-assign property cursor=hand to picture box, One Label to
Display today’s Date and Time and Place one Button to Exit the Application.
3)
Finally, the out put
Screen looks as the follows

ParentForm.cs[Code]:
private void pictureBox2_Click(object sender, EventArgs e)
{
//Creatinf New Instance to open Another Form
frmlogin F = new
frmlogin();
F.Show();
}
private void ParentForm_Load(object sender, EventArgs e)
{
//Displaying Curent Date And Time
label3.Text = System.DateTime.Now.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
//To Quit The Application
Application.Exit();
}
Form1.cs(Login-Design)
Choose any Background as your Choice and Place Label
assign Property Text= Windows Setup and Deployement and Font size=14.25
Design login Form By placing two text boxes , two Labels
,two buttons and one GroupBox as Shown below

3)
Place Merlin
COM Component
Open Tool Box->Right Click On It->select Add Tab->Type tab Name as Merlin
Component->Right Click on the tab and Click on Choose Items ->
Choose Tool Box Opens ->In That Dialog Box Select COM Component.->
In That Components List Select Microsoft Agent Control 2.0-> Click OK->Finally
our toolbox customized as Follows

Drag and Drop MicrosoftAgent Control On To The Form
Open C:\WINDOWS\msagent\chars -> Copy merlin.acs
component and Paste it into our application root as Bin\Debug folder,why
because it is easy to identify that component path in programatical fasion
using Application.StartUpPath.ToString() Method.
6)
Write Code In
Form_Load as Follows
private void frmlogin_Load(object sender, EventArgs e)
{
//Geting Merlin Path Programatically Using String
string merlinPath = Application.StartupPath.ToString() + "\\merlin.acs";
//Loading Merlin Charecter Using Load Method
axAgent1.Characters.Load("Merlin",merlinPath);
//In Order To Store Merlin Use Show() Method
axAgent1.Characters["Merlin"].Show(null);
//At First It Displays at the Left top Corner of The Screen
//So I Moved 270,270 Pixels Backword and DownWord From Top
and Left Posistions of The Screen
axAgent1.Characters["Merlin"].MoveTo(270, 270, null);
/* Some Of Animations I Remembered -Search Google For More
Animations*/
/*Acknowledge, Blink ,Congratulate ,DoMagic2 ,Explain,Greet ,
Hearing_1,Idle1_1,LookUp ,MoveUp,Pleased ,Read ,Sad ,Think,Uncertain,Wave*/
//Just I Used Merlin Animation Charecter
axAgent1.Characters["Merlin"].Play("Read");
axAgent1.Characters["Merlin"].Play("Announce");
axAgent1.Characters["Merlin"].Speak("Third Annual Celebrations www.dotnetfunda.com",null );
axAgent1.Characters["Merlin"].Play("DoMagic1");
}
7)
If The Form Is Loaded
The Following Character Displays First by Showing Some Animation Tricks

Now its is Time To Design Database-
Open Ms access->Create Database Name as
“myDataBase” and Save it into our application root as Bin\Debug folder,why
because it is easy to identify that component path in programmatic fashion
using Application.StartUpPath.ToString() Method.
Design Simple Login Table and Enter Data as Follows
Table Design:
Table Data:

11)
Import Oledb
Namespace and Mention The OledbConnection() Provider In Global Declarations
using System.Data.OleDb;
OleDbConnection strcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=myDataBase.mdb");
12)
Write Code Under
login Button and Cancel Button As Follows
private void btnlogin_Click(object sender, EventArgs e)
{
axAgent1.Characters["Merlin"].Play("Search");
string uname=txtuserName.Text;
OleDbDataAdapter da = new
OleDbDataAdapter("select username,password from login where username='"+txtuserName.Text +"' and password='"+txtpassword.Text +"' ",strcon );
DataSet ds = new DataSet();
da.Fill(ds);
/* Do-Some Actions If User Is Authenticated*/
if (ds.Tables[0].Rows.Count > 0)
{
axAgent1.Characters["Merlin"].Play("Read");
axAgent1.Characters["Merlin"].Play("Announce");
axAgent1.Characters["Merlin"].Speak("Welcome:: " + uname, null);
this.Hide();
MainForm mf = new MainForm();
mf.Show();
axAgent1.Characters["Merlin"].Hide(null);
}
else
{
/* Do-Some Actions If User Is Anonymus*/
axAgent1.Characters["Merlin"].Play("Announce");
axAgent1.Characters["Merlin"].Speak("Sorry You are Not Authorised
User:: "+ uname, null);
}
}
private void btncancel_Click(object sender, EventArgs e)
{
txtpassword.Text = "";
txtuserName.Text = "";
}
Finally The Form Looks As Follows
After Succesful Login it displays MainForm.cs
MainForm.cs
Place One DataGridview and LinkLabel (assign Property
Text=Logout )On The Form
Design Table and Fill Some Data As Follows

3) Filll The Data As Follows

Write Code as Follows In Global Declarations and Form_Load
Event as Well As LinkLabel_Click Event and Import Oledb Namespace
//Import Namespace
using System.Data.OleDb;
//Blobal Declarations
OleDbConnection strcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=myDataBase.mdb");
//Form_Load
private void MainForm_Load(object sender, EventArgs e)
{
OleDbDataAdapter da = new OleDbDataAdapter("select * from dept",strcon );
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0] ;
}
//Under Logout Button
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.Hide();
}
5)
Finally The Screen
Looks as Follows

6)
Please Make Sure That
Place Project Code In A separate Folder [MyFolderName=”MerlinSetUpProject”]
Part - 2 of this article can be read from
http://www.dotnetfunda.com/articles/article927-windows-setup-and-deployement-using-visual-studio--part--2-.aspx
Thank you