Where Did My Icons Go?
Microsoft Visual Studio 2005
Microsoft .NET Framework
Summary: Review the host of improvements and new features that make the Microsoft Visual Studio 2005 integrated development environment (IDE) even more impressive than its predecessors. (16 printed pages)
The introduction of Microsoft Visual Studio 2005 brings a host of improvements and new features that make the integrated development environment (IDE) even more impressive. The changes cover a variety of areas, ranging from how you create Microsoft ASP.NET website projects to new text formatting features. This article will introduce you to some of the changes made to features that exist in prior Visual Studio versions, hopefully allowing you to transition to Visual Studio 2005 faster and easier. Then it will introduce and look at some of the new features added to the Visual Studio 2005 IDE.
The Visual Studio Start Page
The first change you will likely notice as you open Visual Studio 2005 is the new and improved Start Page. In Visual Studio .NET, Microsoft introduced us to the Start Page as a quick and easy way for us to get started using Visual Studio. It made it easy to open projects we used often, create new projects, find online resources, and configure your Visual Studio profile.
Visual Studio 2005 has taken the Start Page and made it even better, simplifying the information on the page and making it easier to understand and use. The new Start Page not only includes the Recent Projects list, it also contains information on how to get started using Visual Studio 2005, along with an ever changing list of helpful news and technical articles gathered from the .NET community.
In addition to the resources listed on the Start Page, Visual Studio 2005 now includes access to a variety of other help and information sources. The IDE deeply integrates both Microsoft and third party community online resources to give you easy access to volumes of information. These additional resources can be found under the new Community menu.
The menu includes options for asking questions, sending feedback, and searching for samples and controls you can use in your projects.
Creating Projects in Visual Studio 2005
Once you are ready to start creating project in Visual Studio 2005 you will notice that how you do this differs from previous IDE versions. Opening the New Project dialog box (File > New > Project), you will see that the project template categories are now organized in a tree view. This allows the dialog box to accommodate the larger variety of project types that are included in Visual Studio 2005.
Additionally, notice that this dialog box does not contain any project templates for creating websites or Web service projects. The IDE now separates the project creation process for these types of projects into their own menu options. If you examine the File > New menu you will see that in addition to the expected Project option, Visual Studio 2005 new offers you the option to create a new website.
Selecting the website option opens the New Website dialog box that contains the ASP.NET project types, including ASP.NET website, ASP.NET Web Service, and the Personal Website Starter Kit.
Notice that, unlike the New Project dialog box, the New Website dialog box does not contain language-specific project types. Instead, the dialog box allows you to select a project type, and then choose the default project language using the following drop-down list.
Finally, one other new feature to this dialog box is the Location drop-down list. This option allows you to tell Visual Studio that you want to create a Web project that is located on a remote server accessible through HTTP or FTP.
Using the Enhanced Toolbox
As the power of Visual Studio grows even the most basic pieces of the IDE must be examined and improved. One of these areas is the Visual Studio Toolbox. Once you have created a new project in Visual Studio 2005, you will quickly notice that the Toolbox has been improved. There are a number of important changes to the Toolbox that will make it easier to use and make you more productive.
First, in prior versions the Toolbox allowed you to categorize controls using the Outlook style Listbar. While this was nice, one large disadvantage was that the Listbar only allowed you to have one control category open at any time. Visual Studio 2005 improves on this by changing the Listbar to allow you to have multiple Toolbox categories open while you develop.
Second, you will notice that the overall number of control categories has increased dramatically, especially in the ASP.NET toolbox. The main reason for this is because of the large increase in the number of controls shipped with Visual Studio 2005. These new categories more effectively organize the in-box controls, making them easier for you to find and making you more productive.
Finally, if you develop both Windows Forms and ASP.NET applications, you will notice that, depending on your currently active project type, the categories in the Toolbox vary greatly. Visual Studio 2005 now hides categories that it thinks you will not need based on the current type of project you are developing. So for instance, if you are creating an ASP.NET Web page you will not see the Common Control category in the Toolbox since it contains all of the common Windows Forms controls, which obviously you cannot use on an ASP.NET Web page. Should you decide you want to see all of the Toolbox categories regardless of your project type, Visual Studio provides a Show All option that will make all Toolbox categories visible. You can access this by right clicking on the Toolbox and selecting the Show All option from the context menu.
Finding and using the Component Tray in ASP.NET
Prior to the introduction of Visual Studio 2000, one irritation for developers was how IDEs like Visual Basic dealt with non-visual controls during design time. Visual Basic included non-visual controls directly on the form surface, which often led to a cluttered form. To keep their design-time form clean, developers would end up piling non-visual icons into the corner of the form, or hiding them behind other controls. Needless to say, this was not a very good design-time experience.
To solve this, Microsoft introduced the Component Tray in Visual Studio 2002 to provide a more appropriate design-time display location for non-visual controls. When developers dropped a non-visual control like the EventLog control onto their form, it was displayed below the design surface.
In Visual Studio 2005, the Component Tray in the Visual Web Developer has changed (though the Component Tray in WinForms projects remains the same). Now in order to add non-visual controls to the form, you need to open the Component Designer surface of your Web page. You can open the Component Designer surface by right-clicking on the file you want to add the control to and selecting the View Component Designer option from the context menu, or by selecting the Component Designer from the View menu.
This opens the Component Designer for your Web page onto which you can drag and drop components as in prior versions.
Note In order to view the Component Designer, you must have chosen to place the code for your Web page in a separate file. You cannot access the Component Designer from Web pages that use inline code only.
Code Beside/Code Separation
One interesting concept that .NET 2.0 introduces is called Partial Classes. The basic idea is that you can separate a type into multiple physical files, or use code generation to dynamically create parts of a type, and merge all of the parts together into a single logical type at runtime.
The introduction of Partial classes into .NET 2.0 has impacted how we create applications in Visual Studio 2005. Partial Classes are now used extensively in both the ASP.NET and the Windows Forms programming models. Evidence of partial classes can be seen in a Web page by examining the code-behind class file. The class declaration is now
Partial Class MyPage Inherits System.Web.UI.Page
Partial class use in Windows Forms can be seen by examining the Designer class that is attached to the default form created by the project template.
Partial Public Class Form1 Inherits System.Windows.Forms.Form
The advantage for Visual Studio in using partial classes is that it can now insulate you from the generated code sections that used to live in the classes. This sections marked "Web Form designer generate code" or "Windows Form Designer generated code" no longer need to live in the physical file. Instead, this code is either extracted to a separate file, as is the case in Windows Forms projects, which now include separate designer files, or it is generated on the fly, as is the case for ASP.NET. This gives you a cleaner slate in which to write your own code and, specifically in ASP.NET, allows for a host of new enhancements such as Master Pages.
The new Accessibility Validation tool in Visual Studio 2005 allows you to validate your Web pages against several different Accessibility Standards, including WCAG Priorities 1 & 2 (http://www.w3.org/TR/WAI-WEBCONTENT/) and Section 508 (http://www.section508.gov/). You can access the tool by selecting Tools > Check Accessibility.
Running this utility verifies that the HTML markup that you are using will conform to the selected standards. Any markup that does not conform is added to the Visual Studio error list.
You can also include Accessibility checking as part of the build process. The Build section of the Website Properties dialog box allows you to add Accessibility validation at both the page and site level. Turning this on will make sure that the website is validated for Accessibility each time you build the project.
Another great addition to Visual Studio 2005 is the Code Analysis FxCop. Many developers are already familiar with this static code analysis tool, but it now comes integrated directly with Visual Studio. You can add static code analysis as part of your website build process by opening the Website Properties dialog box, and selecting the Enable FxCop option from the Build section, or by opening the Code Analysis from the website menu and checking the Enable Code Analysis checkbox. Static code analysis can also be added to other projects by opening the project properties and checking the Enable Code Analysis checkbox on the Code Analysis tab.
Once you have enabled code analysis, the next time you build your solution, analysis rule violations will be added to the Error List.
You can configure the rules that FxCop applies to your code, and the resulting status that each rule will generate by opening the Code Analysis Configuration utility in a website project, or opening the Code Analysis tab in the Project Properties dialog box for all other projects.
The new Code Snippets Manager utility in Visual Studio is an excellent way of managing commonly used pieces of code, giving you quick access to hundreds of inbox code snippets, the ability to create your own snippets, and the ability to search for code snippets shared by others online.
You can add existing code snippets to your code by right-clicking in your code and selecting the Insert Snippet option from the context menu.
Selecting this causes the Insert Snippet Intellisense to appear. Using this, you can navigate the snippet categories and select the snippet you want to insert into your code. For instance, if you want to generate a random number in your Visual Basic code, you can select the Get a Random Number using the Random class snippet from the Math category.
Selecting this snippet inserts the following code into your class:
Dim generator As New Random Dim randomValue As Integer ' Generates numbers between 1 and 5, inclusive. randomValue = generator.Next(1, 6)
You can also add your own code snippets, either writing a snippet from scratch or modifying existing snippets. All of the snippets are stored as .snippet files in C:\Program Files\Microsoft Visual Studio 8\VB\Snippets\1033\
Import Export Settings
Customizing Visual Studio to create the setup that makes you most productive can take time, so if you ever have gotten a new computer, or have had a hardware failure that required a reinstallation of Visual Studio, it was not easy to reconfigure Visual Studio back to your favorite setup. Visual Studio 2005, however, comes with a new utility that allows you to export and import Visual Studio settings.
The Import and Export Settings wizard allows you to selectively pick options to export, and saves the settings to a .vssettings file. You can take this file and move it to another machine, or re-import the file later.
Device Emulator Manager
In Visual Studio 2000, Microsoft added to the development environment powerful tools for creating applications targeted towards devices such as PDAs and mobile phones. Part of the toolset included the ability to plug device emulators into Visual Studio in order to make testing and debugging device applications easier. Most developers who created mobile applications needed to install a number of different device emulators in order to test for cross-device development issues. The Visual Studio IDE, however, lacked the ability to manage the different device emulators that were available in the IDE. Visual Studio 2005 introduces a new Device Emulator Manager to solve this problem.
Visual Studio adds a handy new feature called Bookmarks. As the name implies, Bookmarks are intended to allow you to mark a specific location in your code, and then using either the tools in the Text Editor Toolbar, or the Bookmarks window, easily return to those locations in the future.
Adding Bookmarks to your code can be done by either using the Toggle Bookmark tool, which you can find either on the Text Editor toolbar, in the Edit > Bookmarks menu, or in the Bookmark window.
Once you have added some Bookmarks to your code, there are a number of different ways to organize and navigate through them. The Bookmarks window is the easiest way to display, organize, and access Bookmarks. Open the Bookmarks window by selecting View > Bookmarks. Once the window is open, it will list all bookmarks you have added to the current solution. You can access bookmarks by double clicking the bookmark in the window.
The Bookmarks window also allows you to organize your Bookmarks by creating Bookmark folders and adding individual Bookmarks to them. You can also rename Bookmarks to give them more descriptive names by right-clicking on a Bookmark and selecting the rename option from the context menu. Finally, you can deactivate a Bookmark by unchecking the checkbox next to the Bookmark name. Deactivating a Bookmark means that the Bookmark will be skipped as you cycle through other Bookmarks.
Navigating through existing Bookmarks can be done several ways. The Bookmarks window allows you to cycle through Bookmarks at a file, bookmark, folder, and solution level. The Text Editor Toolbar has options for cycling through existing Bookmarks at a file, folder, or solution level.
You can also add Bookmark shortcuts to the Tasklist window. To add a Bookmark to the Tasklist, simply select the Add Shortcut to Tasklist option from the Edit > Bookmarks menu. You will need to do this for each individual bookmark you want to be listed in the Tasklist. Once you have added some shortcuts, you need to change the Tasklist filter to Shortcuts in order to view them. You can navigate to a particular shortcut by double clicking the shortcut.
Advanced Formatting Options
Having well formatted code is important for the maintainability of your application. Visual Studio 2005 has added a variety of new utilities that help you created well-formatted code. These tool are located in the Edit > Advanced menu. The tools help you apply formatting to your documents using the formatting options set in Visual Studio. These formatting options can be modified using the Visual Studio Options dialog box.
|Format Document||Format the code contained in an entire document according to the formatting rules.|
|Tabify Selected Lines||Convert spaces used for code indentation to tabs.|
|Untabify Selected Lines||Convert tabs used for code indentation to spaces.|
|Make Uppercase||Converts the selected text to all upper case.|
|Make Lowercase||Converts the selected text to all lower case.|
|Delete Horizontal White Space||Remove any preceding white space from each line of code, including spaces and tabs.|
|View White Space||Expose the whitespace character codes in the open document. Using this command you can see exactly where spaces and tabs exist in your document.|
Visual Studio 2005 offers a powerful new IDE that makes writing powerful applications even faster and easier. The changes to the development environment from integrated community resources to the new ASP.NET project model are designed to make the developer's life easier. Additionally, the introduction of a host of new features and utilities like the integrated static code analysis tools and the advanced text formatting options add powerful new functionality to an already powerful development environment.
About the author
Devin Rader is an Infragistics Technology Evangelist and is responsible for authoring Infragistics reference applications and .NET technology articles, as well as the world-wide delivery of Infragistics' technology demonstrations. Devin is an active member and leader for the International .NET Association (INETA), has served as the sole technical editor for numerous works, and is also a contributing author for the soon to be published ASP.NET 2.0 Professional.