- Visual Basic uses references to point to operating system functions that can be called by a programmer. The base class library contains Windows operating system features and methods available via referencing. This base class library possesses many name-spaces that declare classes that are available to a programmer when creating their code. In order to use the functionality of different parts of the operating system you must reference the code library relevant to that feature.
- Name-spaces are logical collections of different features arranged into more easily managed sections. For example, there is a name-space for system input and output, encryption and decryption and speech recognition. Name-spaces contain class definitions that can be instantiated by a programmer as an object. These objects may then be used during runtime to perform various tasks. Failing to add a reference to a specific feature of the operating system results in a compile time error.
Adding a Reference
- A Visual Studio project requires adding a reference to the project and declaring it for use in the code itself. To add a reference to a project simply right click the References heading in the "Solution Explorer" and select "Add Reference..." from the list. This presents a list of possible references for selection by the user. Adding a reference explicitly in code requires the "Using" statement. For example, adding a reference with the "Using" statement for the speech recognition engine requires the following code: "Using System.Speech.Recognition" at the top of the program code.
Win32 and Custom Libraries
- The .NET framework provides a vast array of functionality and reference types. However, it is sometimes necessary to import a reference to a system or custom DLL file. This process requires the "platform invoke," often shortened to "PInvoke," statement. This statement adds a reference and imports a custom library to a Visual Basic project in the .NET environment. Many of the features available in the Win32 API library are available in the base class library. Using the platform invoke method of referencing functions and methods should only be done when there is no native support for the functions desired in the .NET framework.