This documentation is archived and is not being maintained.

ObjRef.TypeInfo Property

Gets or sets the IRemotingTypeInfo for the object that the ObjRef describes.

Namespace:  System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)

public virtual IRemotingTypeInfo TypeInfo { get; set; }

Property Value

Type: System.Runtime.Remoting.IRemotingTypeInfo
The IRemotingTypeInfo for the object that the ObjRef describes.

TypeInfo contains detailed information about the type of remote object represented by the current ObjRef. The current property contains a list of interfaces that the type implements, as well as the type hierarchy. This information might be used to refine the proxy incrementally to adjust to the client's view of the remote object's type.

// a custom ObjRef class that outputs its status
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public class MyObjRef : ObjRef {

   // only instantiate via marshaling or deserialization 
   private MyObjRef() { }

   public MyObjRef(MarshalByRefObject o, Type t) : base(o, t) {
      Console.WriteLine("Created MyObjRef.");
      ORDump();
   }

   public MyObjRef(SerializationInfo i, StreamingContext c) : base(i, c) {
      Console.WriteLine("Deserialized MyObjRef.");
   }

   public override void GetObjectData(SerializationInfo s, StreamingContext c) {
      // After calling the base method, change the type from ObjRef to MyObjRef 
      base.GetObjectData(s, c);
      s.SetType(GetType());
      Console.WriteLine("Serialized MyObjRef.");
   }

   public override Object GetRealObject(StreamingContext context) {

      if ( IsFromThisAppDomain() || IsFromThisProcess() )  {
         Console.WriteLine("Returning actual object referenced by MyObjRef.");
         return base.GetRealObject(context);
      }
      else {
         Console.WriteLine("Returning proxy to remote object.");
         return RemotingServices.Unmarshal(this);
      }
   }   

   public 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 != null) {

         IMessageSink EISinks = EnvoyInfo.EnvoySinks;

         while (EISinks != null) {
            Console.WriteLine("\tSink: " + EISinks.ToString());  
            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
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public class LocalObject : MarshalByRefObject  {

   // overriding CreateObjRef will allow us to return a custom ObjRef 
   public override ObjRef CreateObjRef(Type t) {

      return new MyObjRef(this, t);
   }
}
// a custom ObjRef class that outputs its status
public __gc class MyObjRef : public ObjRef 
{
	// only instantiate via marshaling or deserialization
private:
	MyObjRef() { }

public:
	MyObjRef(MarshalByRefObject* o, Type* t) : ObjRef(o, t) 
	{
		Console::WriteLine(S"Created MyObjRef.");
		ORDump();
	}

public:
	MyObjRef(SerializationInfo* i, StreamingContext c) : ObjRef(i, c) 
	{
		Console::WriteLine(S"Deserialized MyObjRef.");
	}

public:
	void GetObjectData(SerializationInfo* s, StreamingContext c) 
	{
		// After calling the base method, change the type from ObjRef to MyObjRef
		ObjRef::GetObjectData(s, c);
		s->SetType(GetType());
		Console::WriteLine(S"Serialized MyObjRef.");
	}

public:
	Object* GetRealObject(StreamingContext context) 
	{
		if (IsFromThisAppDomain() || IsFromThisProcess()) 
		{
			Console::WriteLine(S"Returning actual Object* referenced by MyObjRef.");
			return ObjRef::GetRealObject(context);
		}
		else 
		{
			Console::WriteLine(S"Returning proxy to remote Object*.");
			return RemotingServices::Unmarshal(this);
		}
	}   

public:
	void ORDump() 
	{
		Console::WriteLine(S" --- Reporting MyObjRef Info --- ");
		Console::WriteLine(S"Reference to {0}.", TypeInfo->TypeName);
		Console::WriteLine(S"URI is {0}.", URI);

		Console::WriteLine(S"\nWriting EnvoyInfo: ");

		if (EnvoyInfo != 0) 
		{
			IMessageSink* EISinks = EnvoyInfo->EnvoySinks;

			while (EISinks != 0) 
			{
				Console::WriteLine(S"\tSink: {0}", EISinks);  
				EISinks = EISinks->NextSink;
			}
		} 
		else
			Console::WriteLine(S"\t {no sinks}");

		Console::WriteLine(S"\nWriting ChannelInfo: ");
		for (int i = 0; i < ChannelInfo->ChannelData->Length; i++)
			Console::WriteLine (S"\tChannel: {0}", ChannelInfo->ChannelData->Item[i]);

		Console::WriteLine(S" ----------------------------- ");
	}
};

// a class that uses MyObjRef
public __gc class LocalObject : public MarshalByRefObject 
{
	// overriding CreateObjRef will allow us to return a custom ObjRef
public:
	ObjRef* CreateObjRef(Type* t) 
	{
		return new MyObjRef(this, t);
	}
};

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: