RemotingServices.IsObjectOutOfAppDomain(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个布尔值,该值指示给定透明代理指定的对象是否包含在与调用当前方法的对象不同的应用程序域中。
public:
static bool IsObjectOutOfAppDomain(System::Object ^ tp);
public static bool IsObjectOutOfAppDomain (object tp);
static member IsObjectOutOfAppDomain : obj -> bool
Public Shared Function IsObjectOutOfAppDomain (tp As Object) As Boolean
参数
- tp
- Object
要检查的对象。
返回
如果该对象在当前应用程序域之外,则为 true
;否则为 false
。
示例
// 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)
注解
有关应用程序域的信息,请参阅 应用程序域。