This documentation is archived and is not being maintained.

ObjRef.TypeInfo Property

Gets or sets the IRemotingTypeInfo for the object that the ObjRef describes.

Namespace:  System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Overridable Property TypeInfo As IRemotingTypeInfo
	Get
	Set

Property Value

Type: System.Runtime.Remoting.IRemotingTypeInfo
The IRemotingTypeInfo for the object that the ObjRef describes.

TypeInfo contains detailed information about the type of remote object represented by the current ObjRef. The current property contains a list of interfaces that the type implements, as well as the type hierarchy. This information might be used to refine the proxy incrementally to adjust to the client's view of the remote object's type.


' a custom ObjRef class that outputs its status
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")>
Public Class MyObjRef
    Inherits ObjRef

    ' only instantiate via marshaling or deserialization
    Private Sub New()
    End Sub

    Public Sub New(ByVal o As MarshalByRefObject, ByVal t As Type)
        MyBase.New(o, t)
        Console.WriteLine("Created MyObjRef.")
        ORDump()
    End Sub

    Public Sub New(ByVal i As SerializationInfo, ByVal c As StreamingContext)
        MyBase.New(i, c)
        Console.WriteLine("Deserialized MyObjRef.")
    End Sub

    Public Overrides Sub GetObjectData(ByVal s As SerializationInfo, ByVal c As StreamingContext)
        ' After calling the base method, change the type from ObjRef to MyObjRef
        MyBase.GetObjectData(s, c)
        s.SetType(Me.GetType())
        Console.WriteLine("Serialized MyObjRef.")
    End Sub

    Public Overrides Function GetRealObject(ByVal context As StreamingContext) As Object

        If IsFromThisAppDomain() OrElse IsFromThisProcess() Then
            Console.WriteLine("Returning actual object referenced by MyObjRef.")
            Return MyBase.GetRealObject(context)
        Else
            Console.WriteLine("Returning proxy to remote object.")
            Return RemotingServices.Unmarshal(Me)
        End If
    End Function

    Public Sub ORDump()

        Console.WriteLine(" --- Reporting MyObjRef Info --- ")
        Console.WriteLine("Reference to {0}.", TypeInfo.TypeName)
        Console.WriteLine("URI is {0}.", URI)

        Console.WriteLine(vbLf & "Writing EnvoyInfo: ")

        If EnvoyInfo IsNot Nothing Then

            Dim EISinks As IMessageSink = EnvoyInfo.EnvoySinks

            Do While EISinks IsNot Nothing
                Console.WriteLine(vbTab & "Sink: " & CType(EISinks, Object).ToString())
                EISinks = EISinks.NextSink
            Loop
        Else
            Console.WriteLine(vbTab & " {no sinks}")
        End If

        Console.WriteLine(vbLf & "Writing ChannelInfo: ")
        For i = 0 To ChannelInfo.ChannelData.Length - 1
            Console.WriteLine(vbTab & "Channel: {0}", ChannelInfo.ChannelData(i))
        Next i

        Console.WriteLine(" ----------------------------- ")
    End Sub
End Class

' a class that uses MyObjRef
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")>
Public Class LocalObject
    Inherits MarshalByRefObject

    ' overriding CreateObjRef will allow us to return a custom ObjRef
    Public Overrides Function CreateObjRef(ByVal t As Type) As ObjRef

        Return New MyObjRef(Me, t)
    End Function
End Class


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: