Runtime errors are easy to diagnose using the new Exception Assistant.
Visual Studio 2005 adds many new features in the area of Windows Forms, both at design and run time; there are simply too many to mention them all here. Two of these features make it far easier to lay out forms just the way you want them—snap lines and in-place property editing.
Snap lines make it easy to align controls with other controls as you layout forms. You might want to align a new control with the top of one control and the right side of another. Figure 12 shows such an arrangement. As you move Button3 so that it's near the edges of Button1 and Button2, the Windows Forms designer displays blue snap lines, as shown in Figure 12. You use these snap lines to align Button3 with the right edge of Button1 and the top edge of Button2.

Figure 12. Snap lines can align controls with the edges of other controls.
As you move Button3 along the height of Button2, the text in Button3 aligns with the text in Button2, and red snap lines indicate this, as shown in Figure 13. If you continue to drag Button3 down, the snap lines shift, as shown in Figure 14. Now, it's simple to align Button3 with the bottom of Button2 and the right of Button1.

Figure 13. Snap lines make it easy to align text in controls.

Figure 14. You can use snap lines to align along any edge.
The Windows Forms designer adds a large number of new controls to its stable of existing controls in the 2005 release. You'll find a new ToolStrip control that augments the existing Toolbar control, adding functionality and behavior that makes it easier to create applications emulating the rich Microsoft Office 2003-style user interface. In addition, there are a number of other useful new controls, including the FlowLayoutPanel, TableLayoutPanel, and managed WebBrowser controls. The SplitContainer control is a huge improvement over laying out Panel and Splitter controls as you might have in previous releases. The DataGridView control is a major improvement over the existing DataGrid control, making it far easier to build the exact user experience that you need.
Working with Data
Although the 2005 release of Visual Studio adds too many data-related features to show them all here, two features really stand out in this new version—the DataSources window and drag-and-drop data binding. Visual Studio .NET 2002 and 2003 did a great job making it easy to bind user interface features to data sources, providing the various data adapter components that you could drag and drop onto a particular form. This technique was certainly easier than writing code, but it did affect maintainability; an individual connection object per form made it tricky to modify the location of your data! In Visual Studio 2005, the project-wide DataSources window provides a holistic view of your application's data.
The DataSources window, as shown in Figure 15, allows you to set up project-wide data sources, selecting items to be used from within the application. When you need to work with a specific data item, you can drag a table or group of fields onto a form, and Visual Studio 2005 can create bound controls for you.

Figure 15. The DataSources window allows you to create project-wide data sources that you can drag and drop onto any design surface. You can also refer to these items programmatically.
Binding data to existing controls couldn't be easier, either. Drag a field from the Data Sources window onto an existing control, and Visual Studio 2005 creates the type of control selected in the Data Sources window, and sets the appropriate binding properties so that you don't need to dig into them yourself. If you have existing controls, you can still drag from the Data Sources window. Drag and drop onto an existing control, and the bindings are set up for you, as well. This type of binding (often called "connect the dots" data binding, simply sets the appropriate data binding properties for existing controls. Whether you're creating bound forms by dragging from the DataSources window, or binding existing controls, you no longer need to maintain your data sources in code, nor in individual components on each form. The DataSources window manages all your data sources for you in one convenient location.
Just My Code
When you create a new project in Visual Basic, the project generally includes a lot of code that you didn't write. Visual Basic 2005 adds the option to always skip over any code that you didn't write as you're single-step debugging through your code. The Enable Just My Code Stepping option (see Figure 16) allows you to control this behavior and is enabled by default.

Figure 16. Just My Code stepping allows you to step over code you didn't write, saving you time and effort.
XML code comments
Documenting your code is a crucial part of an application, and Visual Basic 2005 adds support for creating XML-based comments in your code that can easily be extracted, parsed, and turned into documentation. Outside a procedure, enter ''' (a comment that begins with ''') and then press Enter. Visual Studio 2005 creates the structure of the XML-based comments for you, as shown in Figure 17.

Figure 17. Typing ''' inserts XML-based code comments. Fill in the details, and you can easily create code documentation.
If you supply a description for a parameter in the XML comments as the content of the XML element, developers consuming your method will see IntelliSense help, including your description, as they write their code. You can also select a menu item within Visual Studio that creates Web-based documentation from the XML documentation within your project
ClickOnce Installation and Reg-Free COM
Deploying applications built on the .NET Framework has traditionally been a much simpler process than deploying COM-based applications, but the 2005 release of Visual Studio makes deploying Windows applications even easier. With the addition of ClickOnce functionality, you can create and deploy desktop applications using a safe and simple system-controlled installation and update mechanism, allowing for updates, as needed, from a central location.
Starting with the 1.0 release of .NET, most applications written using the .NET Framework (managed applications) were isolated—all their components were installed local to the application, instead of requiring registration and shared components—and allowed for zero-impact deployment. This solved the DLL problems suffered by COM developers, as they attempted to manage the versions of installed components.
In addition, managed Windows applications have had the capability of running from a Web site, ensuring that their content was always current. Using this approach adds many technological limitations because of security implications. In addition, Windows applications generally run slower over the Web, because parts of the application get downloaded as they're needed, and there's no built-in support for offline use.
ClickOnce technology allows for simple deployment, secure and reliable updates, and it's integrated into Visual Studio. You get the best of both worlds; applications run locally but can be deployed and updated over the Web. ClickOnce makes it easy to install your applications and to provide ongoing updates. Rather than forcing you to distribute new versions of your application, you can deploy updates from a centralized server, updating just the portions of the application that have changed.
ClickOnce can deploy your applications to a client machine from a Web location, from a UNC share, or from a file location (such as a CD). When you deploy your applications using a Web link, users click on a link on a Web page, causing the application to download and install on the client computer. This process creates the necessary Start Menu shortcuts and sets up the item in the Add/Remove Programs dialog box. You can also deploy ClickOnce applications so that they run remotely, and don't install anything locally. (You still have the option of creating a standard MSI file, installing applications as you did in previous versions of Visual Studio, of course.)
Although you can accept all the default options for deploying using ClickOnce, it's instructive to see all the available settings. The Properties dialog box for your project includes a Publish option, as shown in Figure 18. You can specify the location from which users download your application, along with several other options.

Figure 18. Select Publish from within the project's Property pages to configure publishing settings.
Clicking the Updates button displays the dialog box shown in Figure 19. Here you can configure whether your application should check for updates automatically, and if so, how often to perform the updates. ClickOnce-installed applications are smart about updates. If you select to have the updates occur in the background as the application is running, the installer actually tears down and rebuilds the application with the new version while the application is running. You can specify the interval at which you'd like the updates to occur, as well.

Figure 19. Select Updates to configure when and how your application downloads its updates.
Once you've created a project you'd like to deploy using ClickOnce, you can right-click on the project in the Solution Explorer window and select Publish from the context menu. You'll see the dialog box shown in Figure 20. Enter a Web site from which users can download your application.

Figure 20. Publish your project from within Visual Studio.
Next, you can select whether the application will be available both online and offline, or only online. Figure 21 shows the page that allows you to select these settings.

Figure 21. As you post the application, you can determine whether it will be available offline.
Once you've approved the settings (see Figure 22), Visual Studio stores the application at the site you've selected, and allows you to test the deployment by browsing to the site, as shown in Figure 23.

Figure 22. Click Finish to complete the publishing of your application.

Figure 23. Browsing to the download site displays this page.
When you click the deployment link on the installation page, ClickOnce first verifies that all the prerequisites have been installed, and then verifies the installation, as shown in Figure 24. Finally, ClickOnce runs the application, and you can run it later, as well, using the shortcut ClickOnce places on your Start menu.

Figure 24. Users must confirm the installation before installing it on their local hard drive.
Updating the application is easy, as well. Once you make changes to the application and modify the version number within the AssemblyInfo.vb file, redeploy the application using the same settings as before. This creates a new folder on the Web server corresponding to your new version number. Then, when users attempt to run the application, they'll see a dialog box like the one shown in Figure 25, and they'll have the opportunity to download and run the updated version of your applications.

Figure 25. When a new version of your application is available, users get notified as they run the older version.
There's more to ClickOnce than you've seen here, but it's certainly easy to get started deploying your applications using this new, exciting technology.
Developers attempting to deploy applications that take advantage of COM components have always faced a daunting challenge because of the very nature of COM components: they must be globally registered on the target machine. This global registration requirement can cause trouble, especially in terms of versioning and application collision—the feature developers love to hate known as "DLL hell."
Deploying .NET components has always been easier: developers can simply isolate a component with the deployed application, or they can install a shared component in the Global Assembly Cache (GAC), where multiple versions of a component can co-exist side by side. Finally, with the addition of Reg-Free COM, you can have the best of both worlds. You can continue to take advantage of existing COM components, but you won't have to worry about registering the components on the target machine.
To test Reg-Free COM, try this experiment. In Visual Basic 6.0, create a simple ActiveX DLL named VBDemo and include the following method within Class1, the class created by the project template:
Public Function GetPath() As String
GetPath = App.Path
End Function
Build the DLL, saving it in a convenient location. (Remember that when Visual Basic 6.0 builds an ActiveX DLL, it also registers it on the development machine.)
Within Visual Studio 2005, create a new Windows Application project named RegFreeCOMDemo, and set a COM reference to the existing VBDemo DLL. Add a button to the form, and modify the button's Click event handler to call the COM component:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim test As New VBDemo.Class1
MsgBox(test.GetPath)
End Sub
Build the Visual Basic 2005 application, and verify that running the application and clicking the button displays the path from which the COM component runs.
Navigate to the bin\release folder for the RegFreeCOMDemo project. Within the folder, you'll find RegFreeCOMDemo.exe, the main project executable. You'll find RegFreeCOMDemo.exe.config, the configuration file. You'll also find Interop.VBDemo.dll, the interop assembly that makes it possible for your application to communicate with the COM component. What you won't find, however, is VBDemo.dll, the COM component itself.
To prove a point, try unregistering VBDemo.dll. (From the Start | Run menu, type regsvr32 /u \VBDemo.dll, specifying the full path for the COM component.) Run the RegFreeCOMDemo.exe application again, and this time, of course, it fails with an exception when you click the button. Because you unregistered the COM component, the code simply can't find it when it needs it.
To demonstrate Reg-Free COM, you'll need to be able to build your project again, so you must now re-register the COM component. (Use regsvr32 from the Start | Run menu again.) Switch back to Visual Studio, and select the Project | View All Files menu item. Within the Solution Explorer window, expand the References node, and select VBDemo in the list of references. In the Properties window, set the Isolated property to True. (See Figure 26.) Rebuild the project, and switch back to the bin\release folder. (You need to run the project outside of Visual Studio to demonstrate Reg-Free COM.)
