Share via


My.Application.Info.StackTrace Property

Gets the current stack-trace information.

' Usage
Dim value As String = My.Application.Info.StackTrace
' Declaration
Public ReadOnly Property StackTrace As String

Property Value

A String containing the current stack-trace information. The return value can be Empty.

Exceptions

The following condition can cause an exception:

Remarks

The My.Application.Info.StackTrace property lists method calls in reverse chronological order—that is, it describes the most recent method call first, and it lists each method call on the stack on a separate line. However, the My.Application.Info.StackTrace property might not report as many method calls as expected, due to code transformations that occur during optimization.

Typically, the stack-trace information is used for debugging applications.

The stack-trace information for each method call is formatted as follows:

"at FullClassName.MethodName(MethodParams) in FileName:line LineNumber "

The literal "at" is preceded by three spaces, and the literals "in" and ":line" are omitted if debug symbols are not available. The placeholders FullClassName, MethodName, MethodParams, FileName, and LineNumber are replaced by actual values, defined as follows:

Part

Description

FullClassName

The full name of the class, including the namespace.

MethodName

The name of the method.

MethodParams

The list of parameter type/name pairs. Each pair is separated by a comma (,). This information is omitted if MethodName takes zero parameters.

FileName

The name of the source file where the MethodName method is declared. This information is omitted if debug symbols are not available.

LineNumber

The number of the line in FileName that contains the source code from MethodName for the instruction that is on the call stack. This information is omitted if debug symbols are not available.

The My.Applicaiton.Info.StackTrace property provides functionality similar to the StackTrace property.

Example

This example uses the My.Application.Info.StackTrace property to display the stack trace of the application from the point at which the code executes.

MsgBox("Stack trace: " & My.Application.Info.StackTrace)

Requirements

Namespace:Microsoft.VisualBasic.ApplicationServices

Class:AssemblyInfo

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type

Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

Permissions

The following permission may be necessary:

Permission

Description

FileIOPermission

Controls the ability to access information in the file paths. Associated enumeration: PathDiscovery.

For more information, see Code Access Security and Requesting Permissions.

See Also

Reference

My.Application.Info Object

StackTrace

AssemblyInfo.StackTrace