RemotingServices.IsObjectOutOfContext(Object) Méthode

Définition

Retourne une valeur Boolean indiquant si l'objet représenté par le proxy spécifié est contenu dans un contexte différent de celui de l'objet qui a appelé la méthode en cours.

public:
 static bool IsObjectOutOfContext(System::Object ^ tp);
public static bool IsObjectOutOfContext (object tp);
static member IsObjectOutOfContext : obj -> bool
Public Shared Function IsObjectOutOfContext (tp As Object) As Boolean

Paramètres

tp
Object

Objet à vérifier.

Retours

true si l'objet est à l'extérieur du contexte en cours ; sinon false.

Exemples

// Create a remote version of TempConverter::Converter.
TempConverter::Converter^ converter1 =
      dynamic_cast<TempConverter::Converter^>(Activator::GetObject(
      TempConverter::Converter::typeid,
      "http://localhost:8085/TempConverter" ));

// Create a local version of TempConverter::Converter.
TempConverter::Converter^ converter2 = gcnew TempConverter::Converter;

// Returns true, converter1 is remote and in a different appdomain.
System::Runtime::Remoting::RemotingServices::IsObjectOutOfAppDomain( converter1 );

// Returns false, converter2 is local and running in this appdomain.
System::Runtime::Remoting::RemotingServices::IsObjectOutOfAppDomain( converter2 );

// Returns true, converter1 is remote and in a different context.
System::Runtime::Remoting::RemotingServices::IsObjectOutOfContext( converter1 );

// Returns false, converter2 is local and running in this context.
System::Runtime::Remoting::RemotingServices::IsObjectOutOfContext( converter2 );
// Create a remote version of TempConverter.Converter.
TempConverter.Converter converter1 =
        (TempConverter.Converter) Activator.GetObject(
        typeof(TempConverter.Converter),
        "http://localhost:8085/TempConverter");

// Create a local version of TempConverter.Converter.
TempConverter.Converter converter2 = new TempConverter.Converter();

// Returns true, converter1 is remote and in a different appdomain.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(
                        converter1);

// Returns false, converter2 is local and running in this appdomain.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(
                        converter2);

// Returns true, converter1 is remote and in a different context.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfContext(
                        converter1);

// Returns false, converter2 is local and running in this context.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfContext(
                        converter2);
' Create remote version of TempConverter.Converter.
Dim converter1 As TempConverter.Converter

converter1 = CType(Activator.GetObject(GetType( _
                     TempConverter.Converter), _
                     "http://localhost:8085/TempConverter"), _
                     TempConverter.Converter)
' Create local version of TempConverter.Converter.
Dim converter2 As New TempConverter.Converter()

' Returns true, converter1 is remote and in a different appdomain.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain( _
                                                   converter1)

' Returns false, converter2 is local and running in this appdomain.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain( _
                                                   converter2)

' Returns true, converter1 is remote and in a different context.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfContext( _
                                                   converter1)

' Returns false, converter2 is local and running in this context.
System.Runtime.Remoting.RemotingServices.IsObjectOutOfContext( _
                                                   converter2)

Remarques

Un contexte est une séquence ordonnée de propriétés qui définissent un environnement pour les objets qui y résident. Des contextes sont créés pendant le processus d’activation pour les objets configurés pour exiger certains services automatiques tels que la synchronisation, les transactions, l’activation juste-à-temps, la sécurité, etc. Plusieurs objets peuvent coexister dans un contexte.

S’applique à

Voir aussi