Windows DevCenter    
 Published on Windows DevCenter (http://www.windowsdevcenter.com/)
 See this if you're having trouble printing code examples


What Is Visual Studio

by James Avery, author of Visual Studio Hacks
08/22/2005
Use ClickOnce to Deploy Windows Applications
Visual Studio
Visual Studio is a suite of applications created by Microsoft to give developers a compelling development environment for the Windows and .NET platforms. Visual Studio can be used to write console applications, Windows applications, Windows services, Windows Mobile applications, ASP.NET applications, and ASP.NET web services, in your choice of C++, C#, VB.NET, J#, and more. Visual Studio also includes various additional development tools, such as Visual SourceSafe; which tools are included depends greatly on the edition of Visual Studio that you are using.

Microsoft has a long history with development tools (which you know if you have seen any of the TV movies or read any of the books on its history) and Visual Studio is the natural culmination of these efforts. For a number of years, Microsoft shipped individual development tools like Visual C++ and Visual Basic, but starting in 1997 they began offering Visual Studio, which combined all of these environments into one application. (The separate applications are still available for purchase, but are far less popular.)

There have been numerous versions of Visual Studio since its inception. Visual Studio 6 coincided with the release of Visual Basic 6; Visual Studio.NET 2002 was released along with the 1.0 version of the .NET framework, and was again revised with the 1.1 version of the .NET framework, at which point it was dubbed Visual Studio .NET 2003. The next version of Visual Studio, named Visual Studio 2005, is slated for release in November of this year and will coincide with the release of the 2.0 version of the .NET framework.

Capabilities

What can you really do with Visual Studio? Following are some of the various applications that can be built using Visual Studio.

Visual Studio provides an extensible model for adding new projects to Visual Studio; many other Microsoft applications now integrate directly into the IDE. Some of the most common include SQL Server Reporting Services and Visual Studio Tools for Office.

Features

All of the above applications could be written using another IDE or some combination of freely available SDKs and your favorite text editor, so why would you pay for Visual Studio? Visual Studio is dedicated to making your development life easier through time-saving and convenient features; here are some of the most compelling of those features.

Visual Studio includes way too many features to be listed here; even most seasoned developers don't make use of all of the various features available in Visual Studio.

Visual Studio Hacks

Related Reading

Visual Studio Hacks
Tips & Tools for Turbocharging the IDE
By James Avery

Edition Soup

Since the first edition of Visual Studio, there have been various editions that include different sets of applications and features. In the beginning, there were Professional and Enterprise editions; since then, Enterprise has been split into Enterprise Developer and Enterprise Architect editions. I won't get into the specific differences here, but you can read more about the features of each edition on Microsoft's product page for Visual Studio.

In additional to the commercial editions there is also an academic edition of Visual Studio available, which includes all of the features of the Professional edition and some extra instructional features, and is available at a discounted rate.

Note: Some time later this year or next year, Microsoft will launch Visual Studio Team System, which is a new edition of Visual Studio that includes a wealth of new applications designed for enterprise developers. When coupled with Team Foundation Server, it will become a competitor to the products of companies like Rational in the enterprise development space. Visual Studio Team System also includes various versions for specific developer roles such as architect, developer, and tester. This article will focus on the non-Team-System editions of Visual Studio.

Getting Started

It is surprisingly easy to get started writing code with Visual Studio. Launch the Visual Studio application and select New -> Project; you will see the screen shown in Figure 1.

figure 1
Figure 1.

Note: All of the screen shots for this article were taken using Visual Studio 2005 Beta 2; things may differ slightly in Visual Studio.NET 2003 or the final version of Visual Studio 2005.

Visual Studio uses the term "project" to define a collection of files that usually result in a single compiled application or assembly. In this example, select the Windows Application template and click OK. This will create a new project that, when compiled, will create a Windows application. You will also notice that there is a place for the solution name. A solution is a collection of projects that represents your complete business solution. For instance, you might have a Windows application project and a class library project that are both used to build your overall business solution.

After creating a project, Visual Studio will open that project, as is shown in Figure 2.

figure 2
Figure 2.

One thing immediately apparent about this screen is that there are a number of different windows displayed inside of Visual Studio. Each one of these windows can be resized and positioned however you wish. Before going any further, let's take a moment to familiarize ourselves with what is shown here.

The area to the left is the document window. This window is used to open and work with files. The current file is a Windows form, so the window is showing the designer what it would look like if a code file was open (you would see the text of that code file). To the immediate right of the document window is the toolbox. The toolbox holds the various controls that can be dragged on to the design surface; in a moment, we will drag a text box and button from the toolbox to the designer.

Next to the toolbox in the top right is the Solution Explorer. This window is used to keep track of all the projects and files in your solution. You can double-click on a file here to open it in the document window. Below the Solution Explorer is the Properties window. This window displays the available properties and settings for the object you current have open (in this case, the form that is open in the document window).

Expand the Common Controls section of the toolbox and drag a text box and button over to the design surface; where you position the controls is where they will be displayed when the application is run. After dragging the controls to the surface, click once on the button control and you can set the text of the button in the properties window. Set it to something appropriate like "Please click me." Figure 3 shows our progress so far.

figure 3
Figure 3.

Now that the visual elements of the application are laid out, some code needs to be written. Simply double-click the button and you will be shown the code file for this form, as seen in Figure 4.

figure 4
Figure 4.

Since we double-clicked the button, Visual Studio has created a click event handler for that button's click event and placed our cursor inside of the method. Here we can write some simple code to return whatever text was entered in the text box in a message box to the user:


MessageBox.Show(textBox1.Text);

In Figure 5 you can see IntelliSense in action reminding us what the correct method name is on the MessageBox class.

figure 5
Figure 5.

Now that there is some functionality in our application, we can run it in the debugger and see how it works. Place a breakpoint next to the only line of code in the event handler; this is done by clicking on the grey area to the left of the code. When you do this, a small red dot will appear that represents the place where the debugger will stop.

After setting the breakpoint, simply press F5 or click the small play button on the menu. This will compile your application and then launch it, as shown in Figure 6.

figure 6
Figure 6.

Enter some text into the checkbox and then click the button. Instead of showing you a message box right away, the debugger will "break" at your break point and drop you into the debugger, as shown in Figure 7.

figure 7
Figure 7.

A couple of new windows appear in the debugger, most notably the Locals and Call Stack windows. The Locals window shows the variables that are currently in scope and what their value is; you can also drill down into the values of the individual properties on each of the objects. The Call Stack window shows where your application is in its current execution path. From here, you could investigate and change the values of variables, or step through the application line by line. In this case, let's just hit F5 again to let our application continue executing. The message box will be displayed with the contents of the text box, and our application will continue running.

This example is quite simplistic, but it displays some of the most compelling features in Visual Studio and some of the many reasons to use this IDE.

Go Forth and Build

Visual Studio is one of the top IDEs available today for any language or platform and does an incredible job of enabling developers to more efficiently write quality applications using the .NET framework and Windows environment. Visual Studio removes a lot of the pesky and annoying aspects of writing applications and allows you to focus on the application you are writing and the problem you are trying to solve.

Note: Visual Studio is easy to use, but it can be deceptively simple. There are a plethora of features and add-ins you might never become aware of through normal usage. My book, Visual Studio Hacks, points out 100 of these tips, tricks, and tools that you might not otherwise find on your own.

James Avery has been programming with Microsoft technologies for the last 7 years and has been working with .NET since the second beta release.


Return to ONDotNet

Copyright © 2009 O'Reilly Media, Inc.