Udostępnij przez


ITrackingHandler.MarshaledObject(Object, ObjRef) Metoda

Definicja

Powiadamia bieżące wystąpienie o tym, że obiekt został marshaled.

public:
 void MarshaledObject(System::Object ^ obj, System::Runtime::Remoting::ObjRef ^ or);
public void MarshaledObject (object obj, System.Runtime.Remoting.ObjRef or);
[System.Security.SecurityCritical]
public void MarshaledObject (object obj, System.Runtime.Remoting.ObjRef or);
abstract member MarshaledObject : obj * System.Runtime.Remoting.ObjRef -> unit
[<System.Security.SecurityCritical>]
abstract member MarshaledObject : obj * System.Runtime.Remoting.ObjRef -> unit
Public Sub MarshaledObject (obj As Object, or As ObjRef)

Parametry

obj
Object

Obiekt, który został marshaled.

or
ObjRef

Wynik ObjRef z marshalingu i reprezentuje określony obiekt.

Atrybuty

Przykłady

Poniższy przykład kodu pokazuje, jak zaimplementować tę metodę. Ten przykład kodu jest częścią większego przykładu udostępnionego dla interfejsu ITrackingHandler .

// Called when the tracked object is marshaled.

public void MarshaledObject(Object obj, ObjRef objRef)
{
    // Notify the user of the marshal event.
    Console.WriteLine("Tracking: An instance of {0} was marshaled.", 
        obj.ToString());

    // Print the channel information.
    if (objRef.ChannelInfo != null)
    {
        // Iterate over ChannelData.
        foreach(object data in objRef.ChannelInfo.ChannelData)
        {
            if (data is ChannelDataStore)
            {
                // Print the URIs from the ChannelDataStore objects.
                string[] uris = ((ChannelDataStore)data).ChannelUris;
                foreach(string uri in uris)
                    Console.WriteLine("ChannelUri: " + uri);
            }
        }
    }

    // Print the envoy information.
    if (objRef.EnvoyInfo != null)
        Console.WriteLine("EnvoyInfo: " + objRef.EnvoyInfo.ToString());

    // Print the type information.
    if (objRef.TypeInfo != null)
    {
        Console.WriteLine("TypeInfo: " + objRef.TypeInfo.ToString());
        Console.WriteLine("TypeName: " + objRef.TypeInfo.TypeName);
    }

    // Print the URI.
    if (objRef.URI != null)
        Console.WriteLine("URI: " + objRef.URI.ToString());
}

Dotyczy