Export (0) Print
Expand All
Debugger Visualizations, Garbage Collection
Use the Visual Studio 2005 Bootstrapper to Kick-Start Your Installation
CLR Inside Out: Improving Application Startup Time
Unit Testing Tips: Write Maintainable Unit Tests That Will Save You Time And Tears
Program Customized Testing Environments Without Trashing Your Machine
Bridge the Gap Between Development and Operations with Whitehorse
Visual Studio 2005: Create Reusable Project And Item Templates For Your Development Team
Expand Minimize

An Overview of Key New Visual Studio 2005 Features

Visual Studio 2005
 

Microsoft Corporation

November 2005

Applies to:
   Microsoft Visual Studio 2005

Summary: Review many of the new and exciting language features available in the latest release of Microsoft Visual Studio. (55 printed pages)

Contents

Introduction
C# Language Enhancements
Visual Basic Language Enhancements
Productivity Enhancements
Build System and Debugger Enhancements
Windows Forms Enhancements
Data Enhancements
Web Forms Enhancements
Visual Studio Tools for Office (VSTO) Enhancements
Smart Device Enhancements
Conclusion

Introduction

The latest release of Microsoft Visual Studio has been significantly improved by adding innovative language constructs, new compiler features, dramatically enhanced developer productivity, and an improved debugging experience. There are numerous language innovations for both Visual Basic and C#, such as generics, iterators, partial types, and anonymous methods. New Visual Studio 2005 compiler features enable you to do things like disable compiler warnings directly in code or verify ECMA/ISO conformance. The suite of productivity enhancements include refactoring, code expansions, code formatting, enhanced IntelliSense, and much more. The debugging experience has also been improved with new features like enhanced datatips, debugger visualizers, design-time expression evaluation, and more. This document is a sampling of some of the new capabilities available in Visual Studio 2005.

C# Language Enhancements

The following is an introduction to the language enhancements in C# 2.0. Details on these enhancements can be found in the C# 2.0 Language Spec.

C# 2.0 introduces several language extensions, including Generics, Partial Types, Nullable Types, Iterators, and Anonymous Methods.

The language extensions in C# 2.0 were designed to ensure maximum compatibility with existing code. For example, even though C# 2.0 gives special meaning to the words where, yield, and partial in certain contexts, these words can still be used as identifiers. Indeed, C# 2.0 adds no new keywords as such keywords could conflict with identifiers in existing code.

Generic Types

Generics permit classes, structs, interfaces, delegates, and methods to be parameterized by the types of data they store and manipulate. Generics are useful because they provide stronger compile-time type checking, require fewer explicit conversions between data types, and reduce the need for boxing operations and run-time type checks.

For more information about Generics see the Visual C# Developer Center.

Partial Types

Partial types allow classes, structs, and interfaces to be broken into multiple pieces stored in different source files for easier development and maintenance. Additionally, partial types allow separation of machine-generated and user-written parts of types so that it is easier to augment code generated by a tool.

For more information about Partial types see the Visual C# Developer Center.

Nullable Types

Nullable types represent values that possibly are unknown. A nullable type supports all values of its underlying type plus an additional null state. Any value type can be the underlying type of a nullable type. A nullable type supports the same conversions and operators as its underlying type, but additionally provides null value propagation similar to SQL.

For more information about Nullable types see the Visual C# Developer Center.

Iterators

Iterators are methods that incrementally compute and yield a sequence of values. Iterators make it easy for a type to specify how the foreach statement will iterate over its elements.

For more information about Iterators see the Visual C# Developer Center.

Anonymous Methods

Anonymous methods allow code blocks to be written "in-line" where delegate values are expected. Anonymous methods are similar to lambda functions in the Lisp programming language. C# 2.0 supports the creation of "closures" where anonymous methods access surrounding local variables and parameters.

For more information about Anonymous methods see the Visual C# Developer Center.

Refactoring

The Visual C# 2005 IDE now includes robust refactoring support. Refactoring enables you to automate many of the common tasks when restructuring code. For more information on refactoring, please visit the Refactoring home page.

Figure 1 shows the full set of refactoring menu commands as well as a user selecting the Rename command.

ms364072.vs05ovw_01(en-US,VS.80).gif

Figure 1. Using the Rename option from the Refactor menu

A Rename dialog box appears with a field for entering the new name and search/preview options.

ms364072.vs05ovw_02(en-US,VS.80).gif

Figure 2. The Rename dialog box after selecting the Rename menu command

Clicking OK invokes the Preview Changes dialog box as shown in figure 3. This dialog box lists any places in either the comments or code where the name is used. The context menu in the Preview Changes dialog box also lets users jump directly to the line of source code referencing the variable.

ms364072.vs05ovw_03(en-US,VS.80).gif

Figure 3. The Preview Changes dialog box that appears when Rename refactoring is selected

Another common refactoring task is to promote a local variable to a parameter, as in figure 4.

ms364072.vs05ovw_04(en-US,VS.80).gif

Figure 4. Using the Refactor menu to promote a local variable to a parameter

Selecting this option changes the local discount variable declaration to a parameter in the enclosing method's argument signature, as depicted in figure 5. Compare the argument signature here with figure 4.

ms364072.vs05ovw_05(en-US,VS.80).gif

Figure 5. The result of promoting the discount variable to a parameter

Refactoring is also available by using a Smart Tag. You can discover an interface's Smart Tag by clicking on the interface word. This causes a marker to appear under the first letter. Hovering over the interface word with the marker visible causes a Smart Tag icon to appear. You then click the down arrow to view the Smart Tag menu options. Here you see a user selecting the option to implicitly implement the IAnimal interface stubs:

ms364072.vs05ovw_06(en-US,VS.80).gif

Figure 6. Accessing the interface implementation options by using the Smart Tag

This results in stubbed interface methods, a portion of which are seen in figure 7:

ms364072.vs05ovw_07(en-US,VS.80).gif

Figure 7. Part of the stubbed interface

For more information on Refactoring, check out this article by Andrew Troelsen: Refactoring C# Code Using Visual Studio 2005.

Namespace Alias Qualifier

Namespace duplication can be a problem, especially in large projects. Undoubtedly you have encountered situations where you were unable to access members of the Framework BCL because a custom namespace shadowed a System namespace.

The namespace alias qualifier allows you to resolve a symbol using the following syntax: NamespaceAlias::MemberName. For example, if you want to ensure that you are accessing a Framework member you can use the alias global with the qualifier ::, for example, global::System.Collections.Hashtable. If you had a custom class called Hashtable and wanted to work with both in the same namespace, you could create an alias both to the System.Collections namespace and the custom namespace that contains your Hashtable class, using the namespace qualifier to resolve any conflicts:

using SystemAlias = System.Collections;
using MySolutionAlias = MyCompany.Collections;
// Uses System.Collections.Hashtable
// Same as global::System.Collections.Hashtable
SystemAlias::Hashtable 
// Uses MyCompany.Collections.Hashtable
MySolutionAlias::Hashtable

Static Classes

You can now declare a class as static, indicating that it contains only static members. This is very similar to creating a class that contains only static members and a private constructor (which prevents class instantiation). The advantage of using a static class is that the compiler will verify that no instance members are accidentally added, guaranteeing that class instances cannot be created.

Visual Basic Language Enhancements

My

The My namespace provide a sort of "speed dial" that allows you to quickly access, from one line of code, a large array of functionality that previously required considerably more code to duplicate.

ms364072.vs05ovw_08(en-US,VS.80).gif

Figure 8. IntelliSense options when working with the My object

For example, the following brings back the convenient Visual Basic 6-style syntax for accessing Form members by removing the need to explicitly create an instance of the Form:

My.Application.Log.WriteEntry("LogMessage", TraceEventType.Information)
 

You also have direct access from one line of code to Computer information through My.Computer, by which you can easily play audio files or access the file system, the network, or the registry, as well as other computer information. For example:

My.Computer.Audio.Play("Announce.wav")

You also gain quicker access to Resources through My.Resources, various settings through My.Settings, and Web Services through My.WebServices.

XML Comments

The XML Comments feature creates documentation from comments added to your Visual Basic 2005 source code. This makes it easy to update the documentation as you code. This simplifies the documentation process and ensures that code and documentation remain synchronized.

After creating an XML comment describing a section of code you also get IntelliSense on parameters and return types when you type the code in the editor. For example, when you attempt to add a new parameter to the XML documentation section, IntelliSense will prompt you with the parameter name. Also, when first adding comments for a section of code, the XML comments will be auto-populated with the existing parameter names.

In figure 9 you see an example of XML comments for a Click event handler:

ms364072.vs05ovw_09(en-US,VS.80).gif

Figure 9. New XML comment support for Visual Basic

The XML documentation is generated in the same location as the EXE or DLL—for example, the bin\Debug folder.

ms364072.vs05ovw_10(en-US,VS.80).gif

Figure 10. The XML file generated when using XML comments

This XML file can then be programmatically accessed, or modified using an XSLT stylesheet for viewing.

Rename Symbol

The Rename symbol feature helps you to easily rename variables, fields, methods, classes, and modules. Visual Studio 2005 applies the changes to the dependencies automatically so that your code continues to compile.

This feature uses the compiler symbol table instead of merely performing a search-and-replace. This is important because in previous versions, changing the name of a class would cause a significant number of compiler errors. Rename symbol addresses those problems.

Refactoring Support using Refactor

Visual Basic also supports refactoring through the Refactor plug-in from Developer Express. You can find out more information about Refactor on the Visual Basic Developer Center.

Refactor supports the reordering of parameters, extract method, extract property, create overload, and over 10 other refactoring operations.

Continue Statement

The new Continue statement, Continue { Do | For | While }, allows you to transfer from inside a Do, For, or While loop to the loop condition test, short circuiting the iteration logic.

For i As Integer = 0 To 50
     If i = 25 Then Continue For
     Debug.WriteLine(i.ToString)
Next

If you nested loops of different types, a For loop inside of a Do loop, for example, you can skip immediately to the next iteration of any level in the nesting. If you have nested loops of the same type, nested For loops, for example, Continue For skips to the next iteration of the innermost For loop.

Visual Basic 6.0-Style Form Access

Those of you from a Visual Basic 6.0 background will be pleased to know that you can now access members of a Visual Basic Form without having to create an instance variable. If the Form object does not already exist, Visual Basic creates it for you.

Figure 11 shows a Windows Forms project in Visual Studio .NET 2003. If you try to access members of Form2 from Form1 without first instantiating Form2, you get compiler errors:

ms364072.vs05ovw_11(en-US,VS.80).gif

Figure 11. In Visual Studio .NET 2003 you couldn't access another Form's members without first instantiating it

In Visual Basic 2005 this is now possible:

ms364072.vs05ovw_12(en-US,VS.80).gif

Figure 12. In Visual Studio 2005 you do not need to instantiate a Form to access its members

Using Block to Facilitate Resource Management

If you are using a system resource that consumes a large amount of memory, or that other components also want to use, you can now use a Using...End Using block to ensure disposal of a system resource when your code leaves the block for any reason. This includes such resources as a file handle or a COM wrapper. The resource is disposed regardless of how the code exits the block, including an unhandled exception.

In the following code snippet the SqlConnection object is disposed after the message box displays:

Public Sub GetAndShowSqlConnection(ByVal connString As String)
    Using sqlConnectionTest As New SqlConnection(connString)
  sqlConnectionTest.Open()
        MessageBox.Show(sqlConnectionTest.ConnectionString)
    End Using
End Sub

In short, use a Using block any time you want to ensure that the resource being used is made available as soon as possible without having to explicitly dispose of it.

Auto Correct

The AutoCorrect feature allows you to detect and fix errors in your Visual Basic 2005 code faster than ever before. AutoCorrect alerts you to problems such as recursive property access, overlapping catch blocks or case statements, uninitialized objects, and functions with no return statement. Not only will you immediately see the error in your code, but you will also be presented with some suggested actions to correct the bug.

In figure 13 you see what happens when you declare a Load event handler without a closing End Sub statement:

ms364072.vs05ovw_13(en-US,VS.80).gif

Figure 13. The Auto Correct pop window

This assistance is available immediately—no separate compile step is required. This is due to the background compiler, a feature exclusive to Visual Basic.

Productivity Enhancements

Line Revision Marks

Change tracking makes it easy to visualize the differences between saved and unsaved code.

In figure 14 you'll notice that the left border is colored differently for certain sections of code. The border area highlighted in yellow corresponds to new code that has not yet been saved, while the border area highlighted in green corresponds to new code that has been saved. Border areas that are neither yellow nor green reflect code that existed when the file was originally opened.

ms364072.vs05ovw_14(en-US,VS.80).gif

Figure 14. The yellow line revision marks indicate lines that have changed since last saving the code file

Class Designer

Class Designer is a new feature that gives you a "window" into your code by providing a visual design surface for the classes and types in your project. As with other visual designers in Visual Studio 2005, changes made visually are reflected in the code, and vice versa.

Open the Class Designer by clicking the View Class Diagram icon in the Solution Explorer. This creates a .cd file and opens the Class Designer toolbox. Figure 15 depicts an abstract class Animal. It exposes three properties and four methods:

ms364072.vs05ovw_15(en-US,VS.80).gif

Figure 15. The Class Designer

In the Class Details pane (depicted in figure 15) you can add or modify methods, properties, fields, and events. You can also right-click a class and add various items through the Add menu. Figure 16 depicts a user selecting the menu item for adding a new constant to the Dog class:

ms364072.vs05ovw_16(en-US,VS.80).gif

Figure 16. Adding a method to a visually represented class

For C# projects you can also refactor from within the Class Designer. Here you see a user extracting an interface from the abstract Animal class:

ms364072.vs05ovw_17(en-US,VS.80).gif

Figure 17. Extracting an interface from a class in the Class Designer

Selecting the Extract Interface menu option causes a dialog box of the same name to appear. Here you may select which public members will form the extracted interface.

ms364072.vs05ovw_18(en-US,VS.80).gif

Figure 18. Selecting the public members that form the extracted interface

The interface now appears in the Class Designer as a green shaded entity. Figure 19 shows a few other symbols involved. The Interface symbol extends from the top of the Animal class, and the arrow pointing to the Animal class from the Dog class shows that the latter inherits the former.

ms364072.vs05ovw_19(en-US,VS.80).gif

Figure 19. The Class Designer depicting an abstract class that implements an interface, and a concrete class that inherits the abstract class

Snippets

If you are like most developers you spend a large amount of time using search engines and integrated help to look up how to perform common programming tasks. The IntelliSense Code Library offers hundreds of code snippets for immediate use in your applications. This can be a real time-saver.

Each code snippet is self-contained, allowing you to quickly perform tasks such as reading from and writing to files, working with XML, and accessing assembly resources. The library is accessible from anywhere in your code. Most of them are either ready to run or require only slight customization for full integration into your application.

The library of code snippets can be easily extended with your own code snippets from colleagues and third parties, and you can share your custom code snippets, as well. Taking advantage of these code snippets leads to more consistency in the code, less time researching common tasks, and fewer errors.

Figure 20 shows the Visual Basic .NET snippets when you right-click on a code file and select Insert Snippet:

ms364072.vs05ovw_20(en-US,VS.80).gif

Figure 20. The Snippets menu as seen in the Visual Basic IDE

The list of snippets appears organized into category folders, and in some cases sub-category folders. Each category represents a type of snippet such as security, collections, or file input/output. This provides a much faster interface than a single list would provide.

Figure 21 shows how drilling down into a list of snippets leaves a "breadcrumbs trail" of folders (much like navigation on a Web page):

ms364072.vs05ovw_21(en-US,VS.80).gif

Figure 21. The snippets feature leaves "breadcrumbs" to show the location of the currently selected snippet

The highlighted regions in the code snippet provide assistance on portions of the code snippet that can or should be customized. You can hover your mouse over any of these regions. This will display a tool tip with additional information. You can key in new values, using the Tab key to navigate between the regions. This can be invaluable in understanding how a snippet accomplished its actions.

ms364072.vs05ovw_22(en-US,VS.80).gif

Figure 22. Green areas in a snippet indicate the code you need to modify to fully integrate the snippet

There's even a Code Snippets Manager dialog box to help you keep your snippets organized:

ms364072.vs05ovw_23(en-US,VS.80).gif

Figure 23. The Code Snippets Manager

Surround With (C# only)

Another exciting new feature is the ability to surround an existing line of C# code with an expansion. To use this feature, highlight a line of C# code, then right-click and select Surround With (or select the Edit | IntelliSense | Surround With menu option). Figure 24 shows how to place the highlighted statement within the Try block of a Try/Catch construct:

ms364072.vs05ovw_24(en-US,VS.80).gif

Figure 24. Surrounding a highlighted statement with a Try Catch expansion

Pressing Tab or Enter surrounds the statement with the expansion. Your cursor ends up in the blue highlighted region so that you can quickly change the exception type if you desire.

ms364072.vs05ovw_25(en-US,VS.80).gif

Figure 25. The result of surrounding a statement with a Try Catch expansion

Object Test Bench

The Object Test Bench allows you to conduct simple, object-level testing. With it you may create instances of your project's classes, invoke their methods, and view the results. If your class exposes static methods, you may call them without instantiation using the Invoke Static Method menu option. In figure 26 you see a user creating an instance of the Dog class:

ms364072.vs05ovw_26(en-US,VS.80).gif

Figure 26. Creating an instance of the Dog class from within the Class Designer

This brings up a Create Instance dialog box, which allows you to assign a name to the new object:

ms364072.vs05ovw_27(en-US,VS.80).gif

Figure 27. The Create Instance dialog

The new object appears in the Object Test Bench window. You may then right-click the object and select a method to test from the Invoke Method menu:

ms364072.vs05ovw_28(en-US,VS.80).gif

Figure 28. The Invoke Method menu options

Invoking a method causes the Method Call Results dialog box to appear. Here you see the results of a user having invoked the Dog.Speak method. The message states that the method worked properly and returned an appropriate string value.

ms364072.vs05ovw_29(en-US,VS.80).gif

Figure 29. The Method Call Result dialog

Other IntelliSense Enhancements

IntelliSense has been enhanced to understand generic types. In Figure 30, the generic Products property for the Category class instance c2 appears in the object's IntelliSense menu.

ms364072.vs05ovw_30(en-US,VS.80).gif

Figure 30. Generic types appear in an object's IntelliSense menu

IntelliSense has also been enhanced for exceptions. When adding a Try/Catch block, IntelliSense filters the available options to only show a list of exception types.

ms364072.vs05ovw_31(en-US,VS.80).gif

Figure 31. IntelliSense filtering for exceptions

Options filtering also applies to attributes. In figure 32, adding an attribute filters the available options to only show a list of attribute types and related code snippets.

ms364072.vs05ovw_32(en-US,VS.80).gif

Figure 32. IntelliSense filtering for attributes

The IDE now supports auto-using statements for C# using a Smart Tag. (In Visual Basic .NET you get a tool tip telling you to add a reference to a specific assembly.)

For example, consider a situation where you want to type Debug.WriteLine but then discover after typing "Debug" that you get no IntelliSense. Clicking Debug and hovering over it displays a Smart Tag icon. You can then click the down arrow to select either the appropriate "using" statement or the fully qualified name of the class that you want to work with.

ms364072.vs05ovw_33(en-US,VS.80).gif

Figure 33. The Smart Tag menu options for giving you access to a class's members (C# only)

When you select the using directive instead of the class's fully qualified name, it automatically adds the directive to the list of other directives at the top of the file.

When the using directive is added, the class name now appears in blue, indicating that you now have access to it. Full IntelliSense is then available, so you can continue with shorthand dot-notation access of the WriteLine method.

ms364072.vs05ovw_34(en-US,VS.80).gif

Figure 34. Debug changes to blue and full IntelliSense is now available

The Visual Basic .NET IDE has a convenient new namespace member filtering feature that helps you quickly to find the most commonly used members. The following figures show the tabbed IntelliSense menu when accessing members of the Trace class.

ms364072.vs05ovw_35(en-US,VS.80).gif

Figure 35. IntelliSense defaults to the Common (or last selected) tab when accessing namespace or class members (Visual Basic .NET only)

ms364072.vs05ovw_36(en-US,VS.80).gif

Figure 36. You can select the All tab to see all available members for a namespace or class (Visual Basic .NET only)

Source Code Formatting

Source code formatting is always a matter of personal preference, and Visual Studio 2005 includes several options to fully customize and control how your source code is formatted. These formatting options include braces, spacing, indentation, wrapping, and alignment. You also have the choice of having the IDE format code automatically, or just a particular section of source code. Figure 37 shows the formatting new line options for braces as well as a visual preview of the selected formatting option.

ms364072.vs05ovw_37(en-US,VS.80).gif

Figure 37. Formatting options and preview pane

Fonts and Colors

When reviewing source code, one of the easiest ways to distinguish between types and keywords is by using different colors or fonts in the IDE. Visual Studio 2005 greatly expands the number of display items whose appearance you may modify, including a variety of tracepoints (see Debugger Enhancements) and user types.   

ms364072.vs05ovw_38(en-US,VS.80).gif

Figure 38. Different user type and keyword coloring

IDE Settings (Language Defaults/Export/Import/Reset)

When you first run a new installation of Visual Studio 2005 you are prompted to specify how you want to work; as a Visual Basic, C#, or C++ developer, for example. This configures default settings for the IDE, such as F8 for stepping through code if you choose Visual Basic, or F10 if C#. This gives you a head start in customizing the IDE for the way you want to work.

Even more exciting is that Visual Studio 2005 now adds a wizard to help you easily import and export your IDE settings between machines, or to share them with team members. In the past this has been very difficult.

The following serie of figures shows how the Import and Export Settings Wizard helps you export settings. You can also import settings and reset all settings to one of the language-specific settings collection chosen when you first run Visual Studio 2005.

ms364072.vs05ovw_39(en-US,VS.80).gif

Figure 39. Step 1 of the Import and Export Settings Wizard

ms364072.vs05ovw_40(en-US,VS.80).gif

Figure 40. Step 2 of the Import and Export Settings Wizard

ms364072.vs05ovw_41(en-US,VS.80).gif

Figure 41. Step 3 of the Import and Export Settings Wizard

Task List Enhancements

The Task List has been enhanced in Visual Studio 2005. Multiple lines of text can now be displayed in a Task List window row. You can also do single and multiple column sorting, or move columns using drag and drop. Finally, by default only the file name is now displayed instead of the full path, making it easier to see with which file the task is associated. You can change this in the Options dialog box (Tools | Options | Environment).

Open Files Menu

In the upper right of the Code Editor / Design View window is a new Open Files menu. It contains all the files open in the solution. Use it to easily navigate to those open files, especially when many files are open and the tab for a file's window has scrolled out of view.

ms364072.vs05ovw_42(en-US,VS.80).gif

Figure 42. Using the Open Files menu to navigate to a different file open in the Solution

Find All References

Now you can right-click any class or member and find all lines of code that reference it. Although you could do this before with a global Find action, a right-click menu option makes the task easier and quicker.

ms364072.vs05ovw_43(en-US,VS.80).gif

Figure 43. The results of clicking on the Category class and selecting Find All References are displayed in the Find Symbol Result window

Code Definition View

Selecting the View | Other Windows | Code Definition Window (or pressing CTRL+\, CTRL+D) allows you to view the source code for any programmatic element (class, member, and so on) that you click on. For types where the source code is available in your solution, the Code Definition Window will show the source code. For types where source code is not available, the definition window will show the type metadata as source (see the next section on "Go To Definition").

Figure 44 shows what happens when you have the Code Definition window open and you place your cursor in the word "Product" in either line of code.

ms364072.vs05ovw_44(en-US,VS.80).gif

Figure 44. Viewing the source for the Product class in the Code Definition window

Go To Definition Shows Reflected Source (C# only)

In the C# IDE selecting the Go To Definition menu option now takes you to the reflected source code for compiled types for which the source code file is not available in your project. (In Visual Basic .NET you are still taken to the Object Browser Window.) Previous versions of Visual Studio would merely take you to the Object Browser. Here you see a user right-clicking the Form class and selecting Go To Definition:

ms364072.vs05ovw_45(en-US,VS.80).gif

Figure 45. Selecting Go To Definition on Form, a type for which there are no source code files (C# only)

The result is the source code as reflected from metadata in the host assembly.

ms364072.vs05ovw_46(en-US,VS.80).gif

Figure 46. The reflected source resulting from selecting Go To Definition on a compiled type (C# only)

Find Searches Hidden Text by Default

A common request we received for the Find and Replace window was to change the default behavior so that collapsed text, like the text inside a region, is searched by default. In Visual Studio 2003 this behavior is off by default. In Visual Studio 2005, searching hidden text is on by default.

ms364072.vs05ovw_47(en-US,VS.80).gif

Figure 47. Searching hidden text in the find and replace dialog box

Easier Window Docking

To make docking windows easier in the IDE, we now provide you with a set of transparent guides that you can hover over to dock windows. In figure 48 a user is trying to reposition the Toolbox next to the Solution Explorer. When the Toolbox is clicked and dragging begins, the guides appear. Positioning the Toolbox over a specific guide causes the guide to highlight and a blue shaded region to appear, denoting the destination of the Toolbox if you release the mouse button.

Snaplines

Aligning controls in the designer is much easier in Visual Studio 2005. In the following example, when a user drags the Compare Products button, a set of alignment lines appear to visually show how the button is aligned with neighboring controls. Notice both the horizontal and vertical lines.

ms364072.vs05ovw_48(en-US,VS.80).gif

Figure 48. Snaplines make control placement much easier

AutoRecover in the IDE

To prevent loss of information (due to inadvertently closing unsaved file changes, for example) the Visual Studio 2005 now auto saves your work on a regular basis. Should the IDE crash, it will prompt you to recover your work when you restart.

ms364072.vs05ovw_49(en-US,VS.80).gif

Figure 49. Setting your Auto Recover Options

Smart Tags

Tools Support for Strong Naming Assemblies

In Visual Studio 2005 the Project Properties dialog box has been completely redesigned. It now appears as a tabbed window in the center area of the IDE. Moreover, many new project-level features have been added.

To begin with, there is now tools support for strong naming assemblies. In figure 50 a user has selected the "Use a key file" option, which enabled a dropdown menu from which a key file was selected. This caused a Create Strong Name Key dialog box to appear. In the past you would have had to use the Strong Name Tool (sn.exe) and then edit the AssemblyInfo file.

ms364072.vs05ovw_50(en-US,VS.80).gif

Figure 50. Signing a project's assembly

Configurable Security Permissions

Visual Studio 2005 simplifies testing different security credentials by enabling developers to debug their applications with configurable security permissions.

ms364072.vs05ovw_51(en-US,VS.80).gif

Figure 51. Configurable Security settings

Code Analysis Integration

FxCop is integrated into the IDE as part of Visual Studio 2005 Team System. You can find out more about FxCop on the Team System home page.

Figure 52 shows some of the Code Analysis rules supported by Visual Studio 2005. You can enable specific rules or groups of rules, as well as specify whether a rule violation should be flagged as an Error or Warning.

ms364072.vs05ovw_52(en-US,VS.80).gif

Figure 52. Code Analysis settings

Build System and Debugger Enhancements

New Build System

Visual Studio 2005 introduces a new build system called the Microsoft Build Engine, also referred to as MSBuild. MSBuild uses a strongly-typed XML file format based on a published schema to define the build elements. You define the items to be built—along with dependencies and other actions to take—as rules. Rules can even be made reusable by separating sections into different files. Properties are key/value pairs for fields such as output path and assembly name. Build process elements are groups of tasks that comprise a target, such as build, clean, or rebuild. Additionally, if you include this schema in the namespace declaration, you can edit the XML build files with full IntelliSense support. This provides you with a great degree of control for customizing a build process. The XML-based build file makes managing the build process much simpler than make files, as they are hierarchical in nature, better represent the build process, and are easier to edit and extend.

MSBuild is a departure from building in previous versions of Visual Studio as it is written in managed code, with high performance and extensibility as goals. To further differentiate it, MSBuild is built into the .NET Framework 2.0 and can be used even without Visual Studio 2005 installed. However, MSBuild is deeply integrated into the IDE. Every build performed in the IDE actually uses MSBuild, and the project files contain the XML-based build instructions.

Enhanced DataTips and Visualizers

While in debug mode using Visual Studio .NET 2003, you can place the cursor over a simple variable, such as a string, in order to inspect its value. In Visual Studio 2005 this has been greatly enhanced to handle complex types. In figure 53, hovering over the item1 variable causes a DataTip to appear. Hovering over the DataTip causes it to expand, revealing information about the underlying generic type.

Also, with Visual Studio .NET 2003 there wasn't a simple way to see complex types like Datasets, bitmaps, and so forth directly in the debugger. Visualizers are a way to visually represent data while in debug mode. For example, you can visualize the contents of an XML string by selecting the XML Visualizer directly from the DataTip menu as shown in figure 53.

ms364072.vs05ovw_53(en-US,VS.80).gif

Figure 53. An expanded DataTip

Selecting the menu option displays an XML Visualizer dialog box containing the XML representation of the selected variable. Visualizers are also fully extensible so developers and component providers can create custom visualizations for their own types.

Exception Assistant

The new Exception Assistant gives you access to the details about a run-time exception. It also provides troubleshooting tips to help you fix your code more quickly. In figure 54 you see the Exception Assistant telling the developer information about an ArgumentOutOfRangeException.

ms364072.vs05ovw_54(en-US,VS.80).gif

Figure 54. The Exception Assistant popup window

Edit and Continue

Edit and Continue is a powerful feature that allows you to modify source code while a program is in break mode. You can resume execution of your program with the new changes applied. This is a great time-saver, allowing you to make changes without having to stop the debugger, recompile, and re-run your application. (Certain changes such as adding a method or changing the parameters to the current method will not permit Edit and Continue to resume.)

Consider the runtime error shown in the previous section on the new Exception Assistant. In the past you would have to stop the debugger to make the changes. Now simply modify the code highlighted in yellow and press F5 to continue execution! This makes development much faster.

The Options dialog box also allows you to customize how you want Edit and Continue to work:

ms364072.vs05ovw_55(en-US,VS.80).gif

Figure 55. Edit and Continue options

Tracepoints

Tracepoints are a great new way to use breakpoints. If you've ever gotten tired of adding Debug/Trace/Console.WriteLine statements to your code in order to see what's going on, you'll really appreciate this new feature.

Tracepoints allow you to associate a custom action with a breakpoint. When the tracepoint is hit, the debugger performs the specified action instead. To assign an action, right-click the breakpoint and select the When Hit menu option.

ms364072.vs05ovw_56(en-US,VS.80).gif

Figure 56. The first step in creating a tracepoint

This causes the When Breakpoint Is Hit dialog box to appear. Here you may elect to print a message, run a macro, or just continue execution altogether. In figure 57 the user wants to see the first item in a generic List. The braces enable you to write variables or other expressions to the message.

ms364072.vs05ovw_57(en-US,VS.80).gif

Figure 57. Instructing the breakpoint to print a message when the breakpoint is hit

When the breakpoint is hit, the message is written to the Output window. You never had to add any code, and you won't have to remove any code when you want to clean up after debugging.

ms364072.vs05ovw_58(en-US,VS.80).gif

Figure 58. The "When Hit" string as written to the Output Window when execution hits the breakpoint

Unit Testing

Another Visual Studio 2005 Team System feature is code unit testing. To create a test, right-click a line of code and select Create Tests.

ms364072.vs05ovw_59(en-US,VS.80).gif

Figure 59. Creating a unit test

Selecting Create Tests causes a Unit Test Generation dialog box to appear. Here you may configure the test, specifying which classes and members should be included.

ms364072.vs05ovw_60(en-US,VS.80).gif

Figure 60. The Unit Test Generation dialog box

Clicking OK causes Visual Studio 2005 to prompt you to enter a name for your test project. It then creates a Test Project containing test code, which you may then edit and run to perform unit testing. Figure 61 shows the source code for the UnitTest1 class in a test project. Also notice the files that have been added to the solution.

ms364072.vs05ovw_61(en-US,VS.80).gif

Figure 61. The unit test project and test code generated by the IDE

You can run the unit tests from the Test View Window, which is accessible from the Test | View and Author Tests menu option.

ms364072.vs05ovw_62(en-US,VS.80).gif

Figure 62. Opening the Test View Window from the Test menu

Figure 63 shows all test methods selected. If you click the Run Test icon (green arrow), the test commences.

ms364072.vs05ovw_63(en-US,VS.80).gif

Figure 63. Starting a test on the selected methods

The results of the unit test appear in the Test Results window.

ms364072.vs05ovw_64(en-US,VS.80).gif

Figure 64. The Test Results window following a unit test

Windows Forms Enhancements

New UI Controls

Visual Studio 2005 brings you Windows Forms 2.0, and with it a host of exciting new controls, features, and enhancements for building better windows clients faster.

Menu and Toolbar Controls

The design time authoring tools in Visual Studio 2005 make it easy to build rich menu, tool, and status bars similar to those in Office Professional 2003. For a number of years developers have wanted to mimic the look found in Microsoft's currently shipping products. The new ToolStrip family of controls, which includes the MenuStrip and StatusStrip controls, are the .NET Framework 2.0 upgrades of the ToolBar, MainMenu, and StatusBar controls, providing similar functionality in terms of look and feel to that found in Microsoft Office. These controls support rafting, merging, and the reordering of their constituent controls. What's more, they support XP visual styles by default. These enhancements make it easy to create professional looking user interfaces with minimum effort.

ms364072.vs05ovw_65(en-US,VS.80).gif

Figure 65. New controls in the Menus & Toolbars group

For example, the ToolStrip is a powerful and very customizable control for building highly functional professional-looking toolbars. Like the MenuStrip control, it provides two interfaces for designing toolbars: an in-place interactive interface and the Items Collection Editor for ToolStrips.

ms364072.vs05ovw_66(en-US,VS.80).gif

Figure 66. The ToolStrip control and ToolStripItems available to it

Container Controls

The new layout panels TableLayoutPanel and FlowLayoutPanel can be used to mimic the layout behavior of Web applications.

ms364072.vs05ovw_67(en-US,VS.80).gif

Figure 67. New controls in the Containers group

Formerly, controls in Windows Forms were laid out with absolute positioning, which made it difficult to respond to resize events. This was in sharp contrast to Web applications, which support flexible positioning through a variety of table or CSS properties. The new TableLayoutPanel control brings the power and flexibility of Web-based layout to Windows Forms, while the FlowLayoutPanel control allows content to flow freely on Form as it resizes.

ms364072.vs05ovw_68(en-US,VS.80).gif

Figure 68. A Form with controls laid out in a TableLayoutControl, much like you would lay out Web Form controls in an HTML table

Controls contained in a TableLayoutPanel are given two additional properties: ColumnSpan and RowSpan. These properties allow a contained TextBox, for example, to span multiple columns or rows. This functionality is analogous to the RowSpan and ColumnSpan attributes of an HTML table cell.

WebBrowser

Visual Studio 2005 offers much better support for integrating Internet Explorer into your applications. The Visual Studio 2005 toolbox now contains a new WebBrowser control. Although this is still a managed wrapper for the ActiveX control, the wrapper exposes many more browser API members than were available in the past.

ms364072.vs05ovw_69(en-US,VS.80).gif

Figure 69. The WebBrowser control embedded in a Form

The WebBrowser control is very easy to use. For example, you no longer have to write complex code to disable the browser's context menu and keyboard accelerators. Instead, just set the new IsWebBrowserContextMentEnabled and WebBrowserShortcutsEnabled properties. Also, set the Url property, call the Navigate method (or drag a URL onto the control), and the control navigates to that address. Client-side scripts are also fully supported.

The WebBrowser control also provides you a lot of options for restricting what the user can do. For example, you can prevent the user from navigating away from the current page by setting the AllowNavigation property, and you can keep them from dropping HTML files and URLs onto the browser by setting the AllowWebBrowserDrop property. You can even use the Navigating and Navigated event handlers to restrict navigation to a specific domain or Web application.

The new WebBrowser control is a great way to easily integrate Internet Explorer into your Windows Forms applications.

New Data Controls

Data controls have been greatly enhanced in Visual Studio 2005. A suite of new controls have been added to greatly simplify and improve support for the binding, navigation, presentation, and entry of data.

BindingSource

The BindingSource control functions as an intelligent "middle man" component between multiple data sources types and the controls to which the data sources are bound. This new component greatly simplifies the task of binding controls to an underlying data source.

It accomplishes this by providing the following powerful features. First, it acts as a data source manager, providing a layer of indirection between a form's controls and its data. Second, you can change the underlying data source—whether a database, Web service or object—without having to change the bindings of the databound controls at runtime. The BindingSource control also provides for sorting, filtering, and change notifications out-of-the-box. Finally, it can even act as a strongly typed source of data.

Once a BindingSource control is added to a form all further interaction with the underlying data is through the BindingSource object.

BindingNavigator

The BindingNavigator control is a ToolStrip control that provides a VCR-like user interface for moving through data, allowing you easy access to add, delete, record, and more. A BindingNavigator control is also automatically added to the form when you drag fields from the new Data Sources window.

Although you can implement data navigation programmatically with the BindingSource control, the BindingNavigator control gives you a convenient, up-and-ready control you can easily add to your Windows applications; and because it derives from ToolStrip, the BindingNavigator is very customizable.

ms364072.vs05ovw_70(en-US,VS.80).gif

Figure 70. A BindingNavigator control is visible above a DataGridView control for working with products in the AdventureWorks database

DataGridView

The DataGridView replaces the DataGrid control found in Visual Studio 2002 and 2003. It provides a wealth of new features for manipulating, displaying, and adding bound and unbound columns. This includes new column types, the ability to use heterogeneous controls, frozen columns (akin to the Freeze Pane feature in Microsoft Excel), click-and-drag columns, and others. All of these features enable you easily to create richer end user experiences than ever before.

ms364072.vs05ovw_71(en-US,VS.80).gif

Figure 71. A DataGridView control containing a variety of column types and heterogeneous columns

Additionally, support is provided for customizing the data or look-and-feel for selected cells at design time. In the past these controls have been column-based, so you had to change the cell contents or style during the data binding event. You can even use cell-based events that rival the functionality of standalone controls.

MaskedTextBox

The new MaskedTextBox control derives from TextBox and implements data input masking and data type validation. Data masking is a technique that controls the format of the user input data. In other words, character input is restricted to a specific series of characters called a "mask."

This control makes it much quicker and easier to build Forms that contain multiple input fields for entering data of various types and shapes. To implement this in the past you had to use custom logic, usually involving rather complex regular expressions. This laborious task is now almost entirely eliminated.

ms364072.vs05ovw_72(en-US,VS.80).gif

Figure 72. You can specify a predefined or custom mask via the Input Mask dialog

Input masks include restrictions for numeric-only values, lower- or uppercase-only character values, optional numbers or letters, and Culture-aware number, currency, and date formatting characters. Mask literals—characters that are displayed but do not affect data entry—can also be used; for example, for a phone number, (___) ___-____. Additionally, the MaskedTextBox control supports data type validation to handle those cases in which the input mask still allows for invalid data.

XP Theme Support

Visual Studio 2005 improves support for Windows XP Themes in Windows Forms 2.0. Windows XP Theme support allows your Windows Form applications to have a completely modern and up-to-date look and feel. In the past, many of you had difficulty implementing the Windows XP look and feel for your client applications. It was particularly confusing when dealing with EnableVisualStyles() and trying to figure out why certain controls still wouldn't render properly. Moreover, you had to set each control's FlatStyle property to System.

All of these issues have been fixed in Windows Forms 2.0. Applications created with Visual Studio 2005 call EnableVisualStyles() by default. Additionally, the controls render properly without your having explicitly to set the FlatStyle property.

Asynchronous Support with the BackgroundWorker Component

Visual Studio 2005 makes performing tasks asynchronously on background threads easier than ever before with the new BackgroundWorker component. Certain tasks can take a long time to execute, such as Web service calls and file downloads. Without asynchronous operations the main application thread would not be free to serve user interface requests. With the BackgroundWorker component you can easily make your application much more responsive by configuring the component to perform these long-running tasks on background threads.

ClickOnce Deployment

Visual Studio 2005 fully supports ClickOnce deployment technology. ClickOnce is a very flexible and simple way to deploy your Windows Forms applications and keep them updated. You can easily deploy applications from a Web site, file share, or FTP location, allowing end users to download and even run them over a network without first installing them. In fact, running a ClickOnce-deployed application can be as easy as navigating to a URL.

Visual Studio 2005 makes it easy to create and publish applications using ClickOnce. The new Publish Wizard guides the developer through the deployment configuration choices, and when finished, builds the ClickOnce manifest and copies it together with the application components to the specified deployment location. Updates are deployed in the same manner, and may be published to the same location as the initial deployment, or to a different location.

ms364072.vs05ovw_73(en-US,VS.80).gif

Figure 73. Step 1 in the Publish Wizard: this application will be published to a Web site

ms364072.vs05ovw_74(en-US,VS.80).gif

Figure 74. Step 2 in the Publish Wizard: this application will be available offline

ms364072.vs05ovw_75(en-US,VS.80).gif

Figure 75. The user specified that a publish page will be used to retrieve and install the application

The Application Updates dialog box is used to configure the ClickOnce update model, specifying whether the application should check for updates before or after it starts.

ms364072.vs05ovw_76(en-US,VS.80).gif

Figure 76. The Application Updates dialog box, accessible from the Project properties Publish tab

Data Enhancements

Data Source Configuration Wizard

The Data Source Configuration Wizard makes it easy to add a database, Web service, or business object as a data sources to your projects. The wizard presents familiar interfaces for locating and identifying the data source. Once the data source type and location have been determined, the wizard examines the data source to display a treeview of the data objects contained by the data source.

For example, the wizard examines a database's object metadata and displays in the treeview any data object that returns a result set. This includes tables, stored procedures, views, and functions. For Web services, the wizard examines its equivalent metadata schema, the WSDL, and generates a proxy class. And with business objects the wizard uses reflection to determine the members of its API.

ms364072.vs05ovw_77(en-US,VS.80).gif

Figure 77. The Data Source Configuration Wizard

Data Sources Window

Once a data source has been created you can view it in the new Data Sources window. This window presents a treeview display of the data sources, with their objects and properties or tables and columns, as is appropriate. You can drag-and-drop the various items onto a Form and Visual Studio 2005 will automatically generate appropriate data bound controls. A drop down menu for each data source allows you to override the default control types.

If present in the data source the Data Sources window will also recognize DataRelation objects. For example, if the DataSet has a foreign key defining a master-detail relationship between two tables, the details table will be visible as a child node of the master table. If this details object is dragged onto a Form, master-details controls are generated and databound without your writing a single line of code.

Figure 78 shows a collection of data sources from the Northwind database open in the Data Sources window. The user is selecting a different control type for the OrderDate field of the Orders table. Notice also that the Orders table is nested below Customers, indicating a master-details relationship.

ms364072.vs05ovw_78(en-US,VS.80).gif

Figure 78. The Data Sources window

"Connect the Dots" Data Binding

"Connect the Dots" data binding is an exciting new IDE feature that greatly simplifies the task of data binding existing controls.

In the previous section you learned that you can automatically create data bound controls for your Form by simply dragging items from the new Data Sources window. However, if you prefer to manually lay out your controls before specifying the data source, "Connect the Dots" data binding allows you to use the familiar drag-and-drop process to bind a data item in the Data Sources to an existing control.

For example, if you want to associate a field in a database table (for example, FirstName, Product, PhoneNumber,and so on) with a given UI element (for example, a Label or TextBox control), drag that field from the Data Sources window onto the control and Visual Studio 2005 will automatically add the appropriate databinding code, connecting the two without any additional code on your part.

Local Database Connectivity

You can now create file-based database connections to local databases. When you do this using the Configure Data Source Wizard, a copy of the database file is placed in your project.

ms364072.vs05ovw_79(en-US,VS.80).gif

Figure 79. Adding a SQL database to your project

You can also opt to have the wizard store the connection string in an app.config file.

ms364072.vs05ovw_80(en-US,VS.80).gif

Figure 80. The app.config file open in a project containing a local database connection; notice the local copy of the MDF and LDF files in the Solution Explorer

Managed SQL Server 2005 Objects

Visual Studio 2005, in conjunction with Microsoft SQL Server 2005, now gives you extensive support for creating stored procedures and user-defined functions with managed code. You can also easily debug these procedures and functions on both the client and the server.

In Visual Studio 2005 you can create stored procedures, triggers, user-defined functions, user-defined types, and user-defined aggregates using .NET languages such as Visual Basic or C#. Transact-SQL queries that perform algorithmic calculations or complex procedural logic, or that make use of the built-in functionality provided by the Base Class Libraries, will see significant gains when they are converted to managed code. On the other hand, queries that strictly manipulate data are more appropriate for traditional T-SQL.

Creating a SQL Server project is as simple as creating a Microsoft Windows Forms or Microsoft ASP.NET project. Just select the SQL Server Project template, create a connection to a SQL Server 2005 instance, then start adding and creating items.

MARS

Multiple Active Result Sets (MARS) is a new Microsoft ADO.NET feature that allows greater flexibility when executing more than one command against a SQL Server 2005 database. A simple way to think about MARS is that you can now execute other SQL statements without closing outstanding SqlDataReader objects. This means that while one request is outstanding on the server, other requests can be submitted for execution. Note that even though multiple requests can be submitted concurrently, MARS does not imply parallel execution of statements. Rather, it simply improves the programming model.

Web Forms Enhancements

Tools and utilities for creating ASP.NET Web applications are contained in a specialized Visual Web Developer platform integrated into Visual Studio 2005. You will see a quantum leap in Web application development features with the latest Visual Web Developer.

Flexible Web Site Project Types

Visual Web Developer makes it much easier to create and deploy ASP.NET applications. Web sites are no longer dependent on project and solution files. The project file stores no information that is required to run the application. (These settings are now either stored in the Web.config file or are no longer needed.) You can add files to a Web site either in Visual Web Developer or by using Windows Explorer, and the files are automatically part of the Web site.

It's also easier to work in a multi-developer environment because you can add or remove files from a Web site without requiring access to a centralized project file that needs to be constantly updated—especially one that might reside in a source-control system such as Visual SourceSafe.

Standalone Lightweight Development Server

ASP.NET 2.0 ships with a new, non-IIS, lightweight Web server that runs locally on Windows, including Windows XP Home. It is specifically built to run ASP.NET Web pages under the localhost scenario, making it an efficient way to test pages locally without the hassle of configuring numerous IIS settings, creating virtual directories, etc. The only real limitation is that it does not support an SMTP mail server. If your Web application involves sending e-mail messages, you must have access to the IIS SMPT virtual server to test e-mail.

Dynamic Compilation Model

Web application code no longer relies upon the previous compilation model, in which a project's code was compiled into a single assembly. Instead, by default, the new version uses the dynamic compilation model that has always been supported by ASP.NET.

This allows you to test pages in your Web applications without having to compile the entire project. In other words, pages that contain compilation errors do not prevent other pages in the Web site from running. Moreover, you can publish a Web site without any assemblies, as well as make changes to the code for individual pages without having to recompile the entire project. This will lead to a much more enjoyable Web development experience and significant productivity gains.

Improved Code-Behind Model

The improved code-behind model takes advantage of a new language feature known as partial classes. In other words, unlike in ASP.NET 1.x, the code-behind file for a page does not contain the complete class definition. Instead, it includes only the application code you need to work with and customize, such as event handlers. This partial class does not need to include instance variables because ASP.NET infers the control instances from the markup at compile time.

This provides several benefits. First, true separation of code and markup is now achievable, whereas before the interaction between ASP.NET server tags and code-behind made this difficult. Second, it's easier to reference controls because this new model does not require explicit instance variables in the code-behind page. Third, there is less designer-generated code. Finally, the object-oriented programming model is greatly simplified. Multi-level inheritance, in which the code-behind file inherited from the Page class and the .aspx page inherited from the code-behind file, is done away with. In Visual Web Developer, the .aspx page and code-behind file are part of the same class.

Master Pages

Visual Web Developer introduces a new feature called Master Pages, a flexible page-template based system that allows you to "skin" and control the layout of your entire Web site by modifying only one template. This type of "visual inheritance" greatly reduces the maintenance and overall complexity of your Web site. It also gives you the type of WYSIWYG support you would expect in the Design view.

A Master Page is a just another type of file that you add to your project, as seen in figure 81. It has a .master extension.

ms364072.vs05ovw_81(en-US,VS.80).gif

Figure 81. Adding a Master Page to a Web project

You can place any control that you want on a Master Page. Every page that inherits from the Master Page will automatically use the same controls inserted on the Master Page. The content of a child page is placed into a ContentPlaceHolder control. The net result is the entire format and layout of your Web site can be maintained by changing a single file. Figure 82 shows how to configure an existing Web page to use a master page.

ms364072.vs05ovw_82(en-US,VS.80).gif

Figure 82. Configuring an existing content page to use a Master Page

Figure 83 shows a content page open in Visual Web Developer. The gray area is inherited from MasterPage.master and cannot be edited. Content for this page is placed in the Content control.

ms364072.vs05ovw_83(en-US,VS.80).gif

Figure 83. A content page consuming a master page, with HTML in a Content control

New Data Controls

GridView

The GridView control is the successor to the DataGrid control. While Microsoft ASP.NET 2.0 still includes the DetailsGrid control, you are encouraged to take advantage of the new features of the GridView control.

The GridView control enables you to perform many of the same tasks as you would previously perform with the DetailsGrid control. The advantage of the GridView control is that, in many cases, you can perform these tasks without writing any code. The GridView control enables you to:

  • Display a set of database records.
  • Sort a set of database records.
  • Page through a set of database records.
  • Edit a set of database records.

In addition, unlike the DetailsGrid control, the GridView control enables you to sort and page through database records without requiring a postback to the server. The GridView control, optionally, uses client-side script to enable you to sort and page database records without performing a form post.

ms364072.vs05ovw_84(en-US,VS.80).gif

Figure 84. The GridView control with the GridView Tasks smart tag menu open

DetailsView

The DetailsView control is an entirely new control introduced with ASP.NET 2.0 that enables you to work with individual database records. You can use the DetailsView control on its own, to display or edit a single database record. When used in conjunction with the GridView control, you can use the DetailsView control to quickly build master/detail forms.

DataSource Controls

New data source controls simplify data binding by providing a single object in which you can declaratively define the connection, queries (a SQL statement, stored parameter name, or the names of methods to invoke on an object, for example), parameters (with values from a control on the page, from a query string, from Session, or from other sources), and behavior options, such as paging and caching.

In general, you do not need to work directly with the objects that are used to manage data access, such as datasets or data readers. Data source controls create data components under the covers.

ASP.NET provides data source controls for different types of data stores, including SQL (for OLE DB and Open Database Connectivity [ODBC] databases), XML files, and business objects. All data source controls expose the same interface to data controls on the page, so that controls such as DataList and Repeater, and the new GridView control, can bind the same way to any data source control, regardless of the underlying data store it represents, and then display data on the page. The result is that you can use the full array of ASP.NET data controls to work with a wide variety of data sources.

To help you create and configure data source controls, Visual Web Developer includes wizards that help you to create connections, define queries or specify methods to call, and configure parameters.

ms364072.vs05ovw_85(en-US,VS.80).gif

Figure 85. The Data Source Configuration Wizard looks different in Visual Web Developer than for Windows Forms; note also the suite of new Data controls in the Toolbox

Connection String Storage

To help make your Web sites more maintainable and more secure, you can keep connection strings in the Web.config file in a new section designed specifically for connection string storage. When you use Visual Web Developer to create or configure data source controls, you can specify that the connection string be stored in the Web.config file. If you change data sources, you can easily change the connection string in one location rather than having to update all data components on all pages with a new connection string.

New Navigation Controls

Microsoft ASP.NET 2.0 introduces several new navigation controls: the TreeView, SiteMapPath, and Menu controls. These controls are feature-rich and were designed to work in a wide variety of scenarios. They can be used to display static data, site-map data, and even database data. In addition, both controls support a rich client-side experience. The TreeView and Menu controls render JavaScript for uplevel browsers, but they are also compatible with downlevel browsers.

ms364072.vs05ovw_86(en-US,VS.80).gif

Figure 86. The TreeView control bound to a SiteMapDataSource object

New Login Controls

A whole suite of new controls now appear in the Login group of the redesigned Toolbox. These controls allow you to easily create secure Web sites. For example, the LoginView control automatically displays a customized template based on whether the user is anonymous or authenticated.

In figure 87 the user is editing one of the templates for the CreateUserWizard control. This control allows you to quickly create a user interface that enables an end user to create an account for authentication and membership purposes. The smart tag menu offers numerous options for customizing the default control layout and settings.

ms364072.vs05ovw_87(en-US,VS.80).gif

Figure 87. The CreateUserWizard control

New WebParts Controls

Visual Web Developer ships with a comprehensive new Web part management system very similar to SharePoint. Personalization is supported out-of-the box, allowing users, among other things, to drag and drop Web parts on a page. To support this functionality VWD provides the application glue on top of ASP.NET.

ms364072.vs05ovw_88(en-US,VS.80).gif

Figure 88. Drag-and-drop functionality in Visual Web Developer

Document Outline

You can select View | Other Windows | Document Outline (or press CTRL+W,U) and see a hierarchical treenode display of your Web or Windows Form's structure and related components.

ms364072.vs05ovw_89(en-US,VS.80).gif

Figure 89. The Document Outline window (Web Forms version)

This same feature is available for Windows Forms, as you can see in figure 90.

ms364072.vs05ovw_90(en-US,VS.80).gif

Figure 90. The Document Outline window (Windows Forms version)

Tag Outline

Tags for an ASPX page are now visible under the Code Editor and Design View window. The tags are context-sensitive—that is, they change in relation to the HTML context of the current cursor placement. Clicking a tag selects the corresponding tag on the page.

ms364072.vs05ovw_91(en-US,VS.80).gif

Figure 91. Tags for a Web Form are visible under the Code Editor and Design View window

Easier Table Inserts and Manipulation

Working with tables is now much easier. The Insert Table dialog box has a Template menu offering a variety of common table templates.

ms364072.vs05ovw_92(en-US,VS.80).gif

Figure 92. The Insert Table dialog box

Once the table is placed, new selection symbols appear when you move your mouse over the table. These facilitate selecting specific rows and columns:

ms364072.vs05ovw_93(en-US,VS.80).gif

Figure 93. Using a selection symbol to select a column of table cells

Also, when resizing a table cell, the width in pixels is visible as you make your adjustments.

ms364072.vs05ovw_94(en-US,VS.80).gif

Figure 94. Resizing a table column

Visual Studio Tools for Office (VSTO) Enhancements

Project System

VSTO 2005 provides Visual Basic and Visual C# projects for Microsoft Excel 2003 workbooks and templates, Microsoft Word 2003 documents and templates, and Microsoft Outlook 2003 add-ins with the VSTO 2005 extension downloaded separately.

ms364072.vs05ovw_95(en-US,VS.80).gif

Figure 95. VSTO 2005 projects available to you, including Outlook Add-in via the Outlook extension to VSTO 2005

You can click the Show All Files icon in the Solution Explorer to see what Visual Studio 2005 includes in a VSTO 2005 project. In figure 96 you see an Excel workbook project. There are now separate code files for each worksheet, and one for the workbook. Microsoft Office Word 2003 has one code file for the document or template.

ms364072.vs05ovw_96(en-US,VS.80).gif

Figure 96. Excel workbook project files created by Visual Studio 2005

Visual Designer

Word 2003 and Excel 2003 application environments are now fully integrated into the Visual Studio designer. This makes VSTO 2005 development very similar to Windows Forms development. Word documents and Excel worksheets open directly in the IDE, and their respective application menus are merged with the Visual Studio menus and remain visible and functional. So you can open a worksheet or document and use it as a design surface, dragging and dropping controls, adding managed code, and so on, while continuing to use the built-in functionality of Word 2003 or Excel 2003.

Figure 97 shows an Excel worksheet open in Visual Studio 2005. You can see two Windows Forms controls on the design surface, and the merged menus across the top. Note the Excel menu options in the open menu.

ms364072.vs05ovw_97(en-US,VS.80).gif

Figure 97. An Excel worksheet open in the visual designer, with merged Excel menus

Data Model Enhancements

VSTO 2005 significantly improves the ability to build data-centric Word 2003 and Excel 2003 solutions. Enhanced XML support allows mapped schema elements to be exposed as controls that you can programmatically manipulate. These include a typed DataSet, a DataConnector, and new view controls, such as an XmlMappedRange or ListObject view control. Schema-mapping also allows you to create a richer end-user experience through the use of Action Panes.

Improved XML support also takes the form of data/view separation by means of embedded XML data islands that stay synchronized with an external data source. Prior to this, data and view were intertwined. This meant that you had to instantiate Word 2003 or Excel 2003 and program against its object model. By keeping the data in an external data source that synchronizes with a document's embedded data island, you can write data manipulation code that is independent of the Office object models, Excel cells and ranges, and so on.

Data binding provides the synchronization between a document's data island and its associated data source. The data binding methodology is identical to that for Windows Forms.

This separation of data from view also provides a way to cache a document's data for off-line and server-side scenarios. You can programmatically store data within a document's cache by calling an Excel worksheet object's StartCaching method, passing in a DataSet, a DataTable, or any data source object that implements the ICachedType interface. Alternatively, you can use the CachedAttribute attribute. When a document is first opened or requested from a server, its data island is populated with the latest data from the associated data source. This data is then cached, residing within the document's data island for offline use or manipulation by server-side code. You can write code so that changes to the data are propagated to the data source when connection is reestablished.

Actions Pane

First introduced with Microsoft Office 2003, the Actions Pane lets you incorporate a custom user interface directly into your Word and Excel documents. You can use the Actions Pane to provide context-sensitive data entry controls and help while a user is working with a document. This makes it very easy to integrate data from a Web service, database or business object.

ms364072.vs05ovw_98(en-US,VS.80).gif

Figure 98. An Actions Pane in use for an Excel worksheet: the controls you see are Windows Forms controls that are dynamically populated using managed code

With the introduction of the ActionsPane class in VSTO 2005, you can more easily leverage this technology to deliver a variety of services built on the .NET Framework. There is no longer any need to use an XML expansion pack, to map XML, or to do many of the other fairly tedious and complex tasks involved with creating a Smart Document using the previous version of VSTO. Simply drag and drop controls onto the Actions Pane and work with them in the same familiar way as with Windows Forms applications.

Smart Tags

There is now a much simpler way to build smart tags. No longer do you have to use Microsoft Office Smart Tag Lists (MOSTL) to define the recognizer and action to take (limiting you only to a hyperlink action), or to work with the complicated SmartTag DLL. VSTO 2005 introduces a managed Smart Tag class that provides an abstraction of the underlying Smart Tag implementation. The class also provides the ability to build a smart tag by providing a list of terms or regular expressions that greatly reduces the amount of code required to implement a smart tag.

The Currency Converter smart tag in figure 99 was implemented with a small amount of managed code:

ms364072.vs05ovw_99(en-US,VS.80).gif

Figure 99. A custom Smart Tag in a Word 2003 document

Smart Device Enhancements

.NET CF 2.0 Framework Enhancements

The .NET Compact Framework (.NET CF) 2.0 extends the existing functionality found in .NET CF 1.0 with new features, improvements to existing features, and expanded support for classes originally only found in the full .NET Framework. Together, these enhancements enable you to build more reliable, richer, and secure applications in a shorter amount of time.

.NET CF 2.0 base performance improvements include faster allocation times and more aggressive method inlining. The just-in-time (JIT) compiler generates better quality, faster-executing code. The .NET CF 2.0 CLR provides better garbage collection and improves the speed of commonly used code paths. While .NET CF 1.0 uses two JIT compilers, .NET CF 2.0 offers a single, unified compiler for all supported processors.

In the area of security, .NET CF 2.0 adds support for NTLM and Kerberos Authentication.

For XML-related operations, the XmlTextReader and XmlTextWriter classes provide significant performance improvements over previous ways of handling XML data. The XmlSerialization class is new in .NET CF 2.0, making it easier to serialize and deserialize objects to and from XML. .NET CF 2.0 also supports XPath parsing and standards-based support for XML Schemas definition language (XSD) schemas using the XPath and Schema classes, respectively.

NET CF 2.0 also introduces several key improvements in the area of Web Services. Foremost is support for asynchronous Web services. While the asynchronous programming model is already well-established in the full .NET Framework, .NET CF 2.0 brings this technology to smart device development for the first time.

Support for asynchronous operations is found in other areas of .NET CF 2.0, as well. The framework includes support for Multi-Threading Capability programming using the BeginInvoke and EndInvoke methods of the Control class.

Finally, network communication support has been enhanced to support the emerging IPv6 protocol, which will enable you to fully exploit the capabilities of the Internet for mobile application communication.

Integrated IDE Enhancements

Visual Studio 2005 provides a significant step forward for .NET Compact Framework (.NET CF) 2.0 developers. The Forms designer has been enhanced. Integrated development and debugging now exists for solutions consisting of both managed and native code. There is support for shared folders and multiple save states. You now have the ability to target multiple versions of .NET CF. Deployment support has been enhanced with CAB projects. And last but not least, a number of integrated tools for managing databases, including SQL Server 2005 Mobile Edition (SQL Mobile), are now included.

New Controls

Control support in the .NET Compact Framework 2.0 has been significantly improved to provide you access to a richer array of controls, many of which were formerly available only to Windows Forms developers.

DocumentList

Accessing files in a Pocket PC application is now easier with the DocumentList control, which provides file navigation and manipulation operations directly in the application.

In earlier versions of the .NET CF you had to use the SaveFileDialog and OpenFileDialog controls to provide the same services that are now encapsulated in the DocumentList control. SaveFileDialog and OpenFileDialog are still supported in .NET CF 2.0, and they remain appropriate for numerous application scenarios. However, the DocumentList control solves a unique user interface challenge for Pocket PC users by providing additional functionality directly within a single form. This reduces the amount of user interaction required to do basic file operations such as copying, deleting, renaming and moving, thus increasing application performance by removing the need to load multiple forms.

ms364072.vs05ovw_100(en-US,VS.80).gif

Figure 100. A DocumentList control in a Pocket PC 2003 application

MonthCalendar and DateTimePicker

The MonthCalendar and DateTimePicker controls are now available for Pocket PC applications, providing the same rich functionality and ease-of-use as their Windows Forms counterparts. If you coded against previous versions of the .NET CF you faced unique challenges when designing a UI for capturing user input. While the full .NET Framework provided a host of controls for supporting common user input tasks—such as data and time selection—you were typically forced to design work-arounds with user controls or third party solutions.

Using the MonthCalendar control, Pocket PC application users can select a date or range of dates using a visual calendar display. The DateTimePicker allows users to select a single day and/or time, and to display that date/time in a specified format.

ms364072.vs05ovw_101(en-US,VS.80).gif

Figure 101. MonthCalendar and DateTimePicker controls in a Pocket PC 2003 application

HardwareButton

The new HardwareButton control allows you to re-map hardware buttons on a smart device at design-time, all without having to make complex, system-level API calls. This feature enables you to customize hardware buttons to support a variety of application scenarios that go beyond traditional productivity applications such as games.

HardwareButton controls are associated with hardware keys on the Pocket PC as enumerated in Microsoft.WindowsCE.Forms.HardwareKeys.

ms364072.vs05ovw_102(en-US,VS.80).gif

Figure 102. HardwareButton controls under a PictureBox control

ScreenOrientation

Another important innovation for building more flexible and interactive interfaces is the new Forms.ScreenOrientation property. This allows you to change the screen orientation of a Form at either design-time or run-time, making it easy to allow users to switch between a landscape or portrait view.

For example, you could add the following code to the Click event handler of the rotateLeftHardwareButton control you saw in the previous section:

If SystemSettings.ScreenOrientation = ScreenOrientation.Angle0
   SystemSettings.ScreenOrientation = ScreenOrientation.Angle270
Else If SystemSettings.ScreenOrientation = ScreenOrientation.Angle90
   SystemSettings.ScreenOrientation = ScreenOrientation.Angle0
Else If SystemSettings.ScreenOrientation = ScreenOrientation.Angle180
   SystemSettings.ScreenOrientation = ScreenOrientation.Angle90
Else
   SystemSettings.ScreenOrientation = ScreenOrientation.Angle180
End If

This would result in the following when the associated button is pressed on the Pocket PC device:

ms364072.vs05ovw_103(en-US,VS.80).gif

Figure 103. ScreenOrientation code in action with a HardwareButton Click event handler

Notification

The new Notification control can be used to deliver interactive messages to users at runtime. This helps you make the best possible use of screen area while at the same time enhancing the end user's experience.

You can use the Notification control to display runtime help information, for example, or to present status messages regarding background tasks or processes, such as asynchronous Web service operations.

Message balloons can contain plain text or HTML content. The HTML is rendered by the Pocket PC HTML control, and you can respond to values in an HTML form by parsing a response string provided by the ResponseSubmittedEventArgs class.

Conclusion

There are dozens of new features avialable in Microsoft Visual Studio 2005: language constructs, compiler features, developer productivity, an improved debugging experience; language innovations for Visual Basic and C#, including generics, iterators, partial types, and anonymous method; and productivity enhancements include refactoring, code expansions, code formatting, and enhanced IntelliSense. This document is a sampling of some of the new capabilities available in Visual Studio 2005.

Show:
© 2014 Microsoft