Namespace: Microsoft.VisualBasic.CompilerServices
Provides classes and members used by the Visual Basic compiler to support language features.
Classes
-
CompilerServices Class
Contains compiler services for the Visual Basic language.
This class is a foundational component for many Visual Basic language constructs, handling operations like object creation, type conversions, and exception management. It's primarily used internally by the compiler and typically not directly by application developers. -
FieldInfo Class
Represents information about a field.
Used to retrieve metadata about fields within types. -
LateBinding Class
Provides methods for late binding operations.
Enables dynamic invocation of methods and access to properties at runtime, often used in scenarios involving COM interop or dynamic object manipulation. -
OptionStrict Class
Provides functionality for handling Option Strict compilation errors.
Auxiliary class to manage type checking and potential narrowing conversions when Option Strict is enabled.
Structs
-
ObjectFlowControl Structure
Represents control flow operations for objects.
Helps manage flow control for object-based operations, particularly in loops and conditional statements.
Enums
-
CompareMethod Enumeration
Specifies how to compare two objects.
Used to define the comparison logic, such as binary or text-based comparison.
Example Usage (Internal Compiler)
' This is a simplified representation of how the compiler might use these services.
' Actual usage is much more complex and hidden from typical application code.
' Example of implicit type conversion handled by compiler services
Dim implicitNumber As Integer = 123.45 ' Compiler might use a Conversion service
' Example of late binding (less common in modern VB.NET, but illustrative)
Dim dynObj As Object = System.Activator.CreateInstance(Type.GetType("System.Text.StringBuilder"))
Microsoft.VisualBasic.CompilerServices.LateBinding.InvokeMember(dynObj, "Append", Nothing, New Object() {"Hello, World!"})
Console.WriteLine(Microsoft.VisualBasic.CompilerServices.LateBinding.InvokeMember(dynObj, "ToString", Nothing))