Free mag vol1 | Page 652

CHAPTER 15  TYPE REFLECTION, LATE BINDING, AND ATTRIBUTE-BASED PROGRAMMING  Note By default, a Visual Basic project will not display the References folder within the Solution Explorer. To add references in a VB project, use the Project  Add Reference… menu option of Visual Studio. The code is (again) intentionally simple. Imports System.Windows.Forms Imports CommonSnappableTypes Public Class VbSnapIn Implements IAppFunctionality Public Sub DoIt() Implements CommonSnappableTypes.IAppFunctionality.DoIt MessageBox.Show("You have just used the VB snap in!") End Sub End Class Notice that applying attributes in the syntax of Visual Basic requires angle brackets (< >) rather than square brackets ([ ]). Also notice that the Implements keyword is used to implement interface types on a given class or structure. Building an Extendable Windows Forms Application The final step is to create a new C# Windows Forms application (MyExtendableApp) that allows the user to select a snap-in using a standard Windows Open dialog box. If you have not created a Windows Forms application before, begin this final project of the chapter by selecting a Windows Forms Application project from the New Project dialog box of Visual Studio (see Figure 15-7). Figure 15-7. Creating a new Windows Forms project with Visual Studio 594