RemotingServices.IsObjectOutOfContext 方法

返回一个布尔值,该值指示给定代理表示的对象是否包含在与调用当前方法的对象不同的上下文中。

**命名空间:**System.Runtime.Remoting
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public Shared Function IsObjectOutOfContext ( _
    tp As Object _
) As Boolean
用法
Dim tp As Object
Dim returnValue As Boolean

returnValue = RemotingServices.IsObjectOutOfContext(tp)
public static bool IsObjectOutOfContext (
    Object tp
)
public:
static bool IsObjectOutOfContext (
    Object^ tp
)
public static boolean IsObjectOutOfContext (
    Object tp
)
public static function IsObjectOutOfContext (
    tp : Object
) : boolean

参数

  • tp
    要检查的对象。

返回值

如果该对象在当前上下文之外,则为 true;否则为 false

备注

上下文是已排序的一系列属性,这些属性为驻留在其中的对象定义环境。上下文是在对象的激活过程中创建的,这些对象被配置为要求某些自动化服务,例如同步、事务、实时激活、安全性等。多个对象可以存在于一个上下文中。

示例

' Create remote version of TempConverter.Converter.
Dim converter1 As TempConverter.Converter

converter1 = CType(Activator.GetObject(GetType( _
                     TempConverter.Converter), _
                     "https://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)
// Create a remote version of TempConverter.Converter.
TempConverter.Converter converter1 =
        (TempConverter.Converter) Activator.GetObject(
        typeof(TempConverter.Converter),
        "https://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 a remote version of TempConverter::Converter.
TempConverter::Converter^ converter1 =
      dynamic_cast<TempConverter::Converter^>(Activator::GetObject(
      TempConverter::Converter::typeid,
      "https://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 );

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

RemotingServices 类
RemotingServices 成员
System.Runtime.Remoting 命名空间
Context