ObjRef::ChannelInfo Property
.NET Framework (current version)
Gets or sets the IChannelInfo for the ObjRef.
Assembly: mscorlib (in mscorlib.dll)
public: property IChannelInfo^ ChannelInfo { virtual IChannelInfo^ get(); virtual void set(IChannelInfo^ value); }
Property Value
Type: System.Runtime.Remoting::IChannelInfo^The IChannelInfo interface for the ObjRef.
The current property holds information contributed by active channels in the process, when the ObjRef is created (see Marshal for details on marshaling). This information can be used by the channels in other processes or application domains to decide whether or not to create a transport sink to communicate with the object represented by the current instance.
// a custom ObjRef class that outputs its status [System::Security::Permissions::SecurityPermissionAttribute( System::Security::Permissions::SecurityAction::Demand, Flags=System::Security::Permissions::SecurityPermissionFlag::SerializationFormatter)] [System::Security::Permissions::SecurityPermissionAttribute (System::Security::Permissions::SecurityAction::Demand, Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] [System::Security::Permissions::SecurityPermissionAttribute (System::Security::Permissions::SecurityAction::InheritanceDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] public ref class MyObjRef: public ObjRef { private: // only instantiate via marshaling or deserialization MyObjRef(){} public: MyObjRef( MarshalByRefObject^ o, Type^ t ) : ObjRef( o, t ) { Console::WriteLine( "Created MyObjRef." ); ORDump(); } MyObjRef( SerializationInfo^ i, StreamingContext c ) : ObjRef( i, c ) { Console::WriteLine( "Deserialized MyObjRef." ); } virtual void GetObjectData( SerializationInfo^ s, StreamingContext c ) override { // After calling the base method, change the type from ObjRef to MyObjRef ObjRef::GetObjectData( s, c ); s->SetType( GetType() ); Console::WriteLine( "Serialized MyObjRef." ); } virtual Object^ GetRealObject( StreamingContext context ) override { if ( IsFromThisAppDomain() || IsFromThisProcess() ) { Console::WriteLine( "Returning actual Object* referenced by MyObjRef." ); return ObjRef::GetRealObject( context ); } else { Console::WriteLine( "Returning proxy to remote Object*." ); return RemotingServices::Unmarshal( this ); } } void ORDump() { Console::WriteLine( " --- Reporting MyObjRef Info --- " ); Console::WriteLine( "Reference to {0}.", TypeInfo->TypeName ); Console::WriteLine( "URI is {0}.", URI ); Console::WriteLine( "\nWriting EnvoyInfo: " ); if ( EnvoyInfo != nullptr ) { IMessageSink^ EISinks = EnvoyInfo->EnvoySinks; while ( EISinks != nullptr ) { Console::WriteLine( "\tSink: {0}", EISinks ); EISinks = EISinks->NextSink; } } else Console::WriteLine( "\t {no sinks}" ); Console::WriteLine( "\nWriting ChannelInfo: " ); for ( int i = 0; i < ChannelInfo->ChannelData->Length; i++ ) Console::WriteLine( "\tChannel: {0}", ChannelInfo->ChannelData[ i ] ); Console::WriteLine( " ----------------------------- " ); } }; // a class that uses MyObjRef public ref class LocalObject: public MarshalByRefObject { public: // overriding CreateObjRef will allow us to return a custom ObjRef [System::Security::Permissions::SecurityPermissionAttribute (System::Security::Permissions::SecurityAction::LinkDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] virtual ObjRef^ CreateObjRef( Type^ t ) override { return gcnew MyObjRef( this,t ); } };
.NET Framework
Available since 1.1
Available since 1.1
Show: