OPC Studio User's Guide and Reference
AsObject Method (_InteropHelper)



OpcLabs.BaseLib Assembly > OpcLabs.BaseLib.ComInterop.ComTypes Namespace > _InteropHelper Interface : AsObject Method
The object to be cast.
Casts the input argument to an System.Object.
Syntax
'Declaration
 
<CanBeNullAttribute()>
Function AsObject( _
   ByVal obj As Object _
) As Object
'Usage
 
Dim instance As _InteropHelper
Dim obj As Object
Dim value As Object
 
value = instance.AsObject(obj)
[CanBeNull()]
object AsObject( 
   object obj
)
[CanBeNull()]
Object^ AsObject( 
   Object^ obj
) 

Parameters

obj
The object to be cast.

Return Value

Returns the input argument, cast to an System.Object.
Remarks

This method is useful in some COM tools (such as PHP) that do not allow to navigate between COM interfaces of an object, or provide an "amalgamated" set of members from multiple interfaces, when a specific interface is returned by a property or method. This leads to a problem if you want to downcast the object you have to a derived type. By passing the object through this method, the consuming COM tool is forced to use late binding, allowing the intended members be accessed.

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also