Customizing Which Objects are Available in My

This topic describes how you can control which My objects are enabled by setting your project's _MYTYPE conditional-compilation constant. The Visual Studio Integrated Development Environment (IDE) keeps the _MYTYPE conditional-compilation constant for a project in sync with the project's type.

You must use the /define compiler option to set the _MYTYPE conditional-compilation constant. When specifying your own value for the _MYTYPE constant, you must enclose the string value in backslash/quotation mark (\") sequences. For example, you could use:

The _MYTYPE conditional-compilation constant, in turn, controls the values of several other _MY compilation constants:

_MYTYPE

_MYAPPLICATIONTYPE

_MYCOMPUTERTYPE

_MYFORMS

_MYUSERTYPE

_MYWEBSERVICES

"Console"

"Console"

"Windows"

Undefined

"Windows"

TRUE

"Custom"

Undefined

Undefined

Undefined

Undefined

Undefined

"Empty"

Undefined

Undefined

Undefined

Undefined

Undefined

"Web"

Undefined

"Web"

FALSE

"Web"

FALSE

"WebControl"

Undefined

"Web"

FALSE

"Web"

TRUE

"Windows" or ""

"Windows"

"Windows"

Undefined

"Windows"

TRUE

"WindowsForms"

"WindowsForms"

"Windows"

TRUE

"Windows"

TRUE

"WindowsFormsWithCustomSubMain"

"Console"

"Windows"

TRUE

"Windows"

TRUE

By default, undefined conditional-compilation constants resolve to FALSE. You can specify values for the undefined constants when compiling your project to override the default behavior.

Note:

When _MYTYPE is set to "Custom", the project contains the My namespace, but it contains no objects. However, setting _MYTYPE to "Empty" prevents the compiler from adding the My namespace and its objects.

This table describes the effects of the predefined values of the _MY compilation constants.

Constant

Meaning

_MYAPPLICATIONTYPE

Enables My.Application, if the constant is "Console," Windows," or "WindowsForms":