How My Depends on Project Type (Visual Basic)

 

Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

My exposes only those objects required by a particular project type. For example, the My.Forms object is available in a Windows Forms application but not available in a console application. This topic describes which My objects are available in different project types.

My exposes only objects that are useful in the current project type; it suppresses objects that are not applicable. For example, the following image shows the My object model in a Windows Forms project.

Shape of My in a Windows Forms application

In a Web site project, My exposes objects that are relevant to a Web developer (such as the My.Request and My.Response objects) while suppressing objects that are not relevant (such as the My.Forms object). The following image shows the My object model in a Web site project:

Shape of My in a Web application

The following table shows which My objects are enabled by default for eight project types: Windows application, class Library, console application, Windows control library, Web control library, Windows service, empty, and Web site.

There are three versions of the My.Application object, two versions of the My.Computer object, and two versions of My.User object; details about these versions are given in the footnotes after the table.

My ObjectWindows ApplicationClass LibraryConsole ApplicationWindows Control LibraryWeb Control LibraryWindows ServiceEmptyWeb Site
My.ApplicationYes 1Yes 2Yes 3Yes 2NoYes 3NoNo
My.ComputerYes 4Yes 4Yes 4Yes 4Yes 5Yes 4NoYes 5
My.FormsYesNoNoYesNoNoNoNo
My.LogNoNoNoNoNoNoNoYes
My.RequestNoNoNoNoNoNoNoYes
My.ResourcesYesYesYesYesYesYesNoNo
My.ResponseNoNoNoNoNoNoNoYes
My.SettingsYesYesYesYesYesYesNoNo
My.UserYes 6Yes 6Yes 6Yes 6Yes 7Yes 6NoYes 7
My.WebServicesYesYesYesYesYesYesNoNo

1 Windows Forms version of My.Application. Derives from the console version (see Note 3); adds support for interacting with the application's windows and provides the Visual Basic Application model.

2 Library version of My.Application. Provides the basic functionality needed by an application: provides members for writing to the application log and accessing application information.

3 Console version of My.Application. Derives from the library version (see Note 2), and adds additional members for accessing the application's command-line arguments and ClickOnce deployment information.

4 Windows version of My.Computer. Derives from the Server version (see Note 5), and provides access to useful objects on a client machine, such as the keyboard, screen, and mouse.

5 Server version of My.Computer. Provides basic information about the computer, such as the name, access to the clock, and so on.

6 Windows version of My.User. This object is associated with the thread's current identity.

7 Web version of My.User. This object is associated with the user identity of the application's current HTTP request.

ApplicationBase
Computer
Log
User
Customizing Which Objects are Available in My
Conditional Compilation
/define (Visual Basic)
My.Forms Object
My.Request Object
My.Response Object
My.WebServices Object

Show: