Figure 13-1 shows the Solution Explorer window for a solution that contains two projects. The solution named MySolution contains two projects named WindowsApplication1 and WindowsApplication2. Each project contains a My Project item that represents the project’s properties, various files containing project configuration settings, and a form named Form1.
In WindowsApplication2, the Show All Files button has been clicked (the highlighted button third from the right at the top of the picture) so that you can see all the project’s files. WindowsApplication1 has similar files, but they are hidden by default.
These files are generated by Visual Basic for various purposes. For example, Resources.resx contains resources used by the project and Settings.settings contains project settings.
The following list describes the files contained in WindowsApplication2 and shown in Figure 13-1. The exact files you see for an application may be different from those shown here, but this list should give you an idea of what’s involved in building a project. Note that most of these files are generated automatically by Visual Studio and you shouldn’t edit them manually. If you change them directly, you are likely to lose your changes when Visual Studio rebuilds them and you may even confuse Visual Studio.
MessageBox.Show(My.Resources.Greeting)
If My.Settings.UserMode = "Clerk" Then ...
Some projects may have other hidden files. For example, when you add controls to a form, the designer adds a resource file to the form to hold any resources needed by the controls.
Normally, you do not need to work directly with the hidden files, and doing so can mess up your application. At best, the changes you make will be lost. At worst, you may confuse Visual Studio so it can no longer load your project.
Instead you should use other tools to modify the hidden files indirectly. For example, the files Resources.Designer.vb, Settings.Designer.vb, and Form1.Designer.vb are automatically generated when you modify their corresponding source files Resources.resx, Settings.settings, and Form1.vb.
You don’t even need to work with all of those source files directly. For example, if you double-click the My Project item in Solution Explorer, the property pages shown in Figure 13-2 appear. The Application tab shown in this figure lets you set high-level application settings. The View Application Events button at the bottom right of the figure lets you edit the application-level events stored in ApplicationEvents.vb.
The References tab shown in Figure 13-2 lets you view, add, and remove project references. As you can probably guess, the Resources and Settings tabs let you edit the project’s resources and settings.
A particularly important section hidden away in these tabs is the assembly information. When you click the Assembly Information button shown in Figure 13-2, the dialog box shown in Figure 13-3 appears.
Many of the items in this dialog box, such as the application’s title and description, are self-explanatory. They are simply strings that the assembly carries around for identification. The assembly and file versions are used by the Visual Studio run time to verify compatibility between an application’s components. The GUID (which stands for “globally unique identifier” and is pronounced to rhyme with “squid”) uniquely identifies the assembly and is generated by Visual Studio. The Make Assembly COM-Visible check box lets you determine whether the assembly should make types defined in the assembly visible to COM applications. For more information on this dialog box, see http://msdn2.microsoft.com/1h52t681.aspx.
The My.Application.Info namespace provides easy access to these values at run time. Example program ShowAssemblyInfo uses the following code to display this information in a series of labels when it starts:
Private Sub Form1_Load() Handles MyBase.Load
lblCompanyName.Text = My.Application.Info.CompanyName
lblDescription.Text = My.Application.Info.Description
lblCopyright.Text = My.Application.Info.Copyright
lblTrademark.Text = My.Application.Info.Trademark
lblDirectoryPath.Text = My.Application.Info.DirectoryPath
lblProductName.Text = My.Application.Info.ProductName
lblTitle.Text = My.Application.Info.Title
lblVersion.Text = My.Application.Info.Version.ToString
End Sub