How My Depends on Project Type (Visual Basic)
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 in Windows Applications and Web Sites
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.
In a Web site project,
My exposes objects that are relevant to a Web developer (such as the
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:
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 Object||Windows Application||Class Library||Console Application||Windows Control Library||Web Control Library||Windows Service||Empty||Web Site|
||Yes 1||Yes 2||Yes 3||Yes 2||No||Yes 3||No||No|
||Yes 4||Yes 4||Yes 4||Yes 4||Yes 5||Yes 4||No||Yes 5|
||Yes 6||Yes 6||Yes 6||Yes 6||Yes 7||Yes 6||No||Yes 7|
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.
Customizing Which Objects are Available in My
/define (Visual Basic)