Export (0) Print
Expand All

ConsoleApplicationBase Class

Provides properties, methods, and events related to the current application.

Namespace:  Microsoft.VisualBasic.ApplicationServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

[HostProtectionAttribute(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
public class ConsoleApplicationBase : ApplicationBase

The ConsoleApplicationBase type exposes the following members.

Public methodConsoleApplicationBaseInitializes a new instance of the ConsoleApplicationBase class.

Public propertyCommandLineArgsGets a collection containing the command-line arguments as strings for the current application.
Public propertyCultureGets the culture that the current thread uses for string manipulation and string formatting. (Inherited from ApplicationBase.)
Public propertyDeploymentGets the current application's ClickOnce deployment object, which provides support for updating the current deployment programmatically and support for the on-demand download of files.
Public propertyInfoGets an object that provides properties for getting information about the application's assembly, such as the version number, description, and so on. (Inherited from ApplicationBase.)
Protected propertyInternalCommandLineSets the values to use as the current application's command-line arguments.
Public propertyIsNetworkDeployedGets a Boolean that represents whether the application was deployed from a network using ClickOnce.
Public propertyLogGets an object that provides properties and methods for writing event and exception information to the application's log listeners. (Inherited from ApplicationBase.)
Public propertyUICultureGets the culture that the current thread uses for retrieving culture-specific resources. (Inherited from ApplicationBase.)

Public methodChangeCultureChanges the culture used by the current thread for string manipulation and for string formatting. (Inherited from ApplicationBase.)
Public methodChangeUICultureChanges the culture that the current thread uses for retrieving culture-specific resources. (Inherited from ApplicationBase.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnvironmentVariableReturns the value of the specified environment variable. (Inherited from ApplicationBase.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The properties exposed by the My.Application object return data that is associated only with the current application or DLL. No system-level information can be altered with My.Application.

The My.Application object consists of the following classes:

  • ApplicationBase provides members that are available in all projects.

  • WindowsFormsApplicationBase provides members available in Windows Forms applications.

  • ConsoleApplicationBase provides members available in console applications.


The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Resources. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

This example uses the My.Application.CommandLineArgs property to examine the application's command-line arguments. If an argument is found that starts with /input=, the rest of that argument is displayed.

Private Sub ParseCommandLineArgs()
    Dim inputArgument As String = "/input=" 
    Dim inputName As String = "" 

    For Each s As String In My.Application.CommandLineArgs
        If s.ToLower.StartsWith(inputArgument) Then
            inputName = s.Remove(0, inputArgument.Length)
        End If 

    If inputName = "" Then
        MsgBox("No input name")
        MsgBox("Input name: " & inputName)
    End If 
End Sub

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft