RealProxy.InitializeServerObject(IConstructionCallMessage) Method

Definition

Initializes a new instance of the object Type of the remote object that the current instance of RealProxy represents with the specified IConstructionCallMessage.

C#
public System.Runtime.Remoting.Activation.IConstructionReturnMessage InitializeServerObject(System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg);
C#
[System.Runtime.InteropServices.ComVisible(true)]
public System.Runtime.Remoting.Activation.IConstructionReturnMessage InitializeServerObject(System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg);
C#
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public System.Runtime.Remoting.Activation.IConstructionReturnMessage InitializeServerObject(System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg);

Parameters

ctorMsg
IConstructionCallMessage

A construction call message that contains the constructor parameters for the new instance of the remote object that is represented by the current RealProxy. Can be null.

Returns

The result of the construction request.

Attributes

Exceptions

The immediate caller does not have UnmanagedCode permission.

Examples

C#
public override IMessage Invoke(IMessage myMessage)
{
   Console.WriteLine("MyProxy 'Invoke method' Called...");
   if (myMessage is IMethodCallMessage)
   {
      Console.WriteLine("IMethodCallMessage");
   }
   if (myMessage is IMethodReturnMessage)
   {
      Console.WriteLine("IMethodReturnMessage");
   }
   if (myMessage is IConstructionCallMessage)
   {
      // Initialize a new instance of remote object
      IConstructionReturnMessage myIConstructionReturnMessage =
         this.InitializeServerObject((IConstructionCallMessage)myMessage);
      ConstructionResponse constructionResponse = new
         ConstructionResponse(null,(IMethodCallMessage) myMessage);
      return constructionResponse;
   }
   IDictionary myIDictionary = myMessage.Properties;
   IMessage returnMessage;
   myIDictionary["__Uri"] = myUri;

   // Synchronously dispatch messages to server.
   returnMessage = ChannelServices.SyncDispatchMessage(myMessage);
   // Pushing return value and OUT parameters back onto stack.
   IMethodReturnMessage myMethodReturnMessage = (IMethodReturnMessage)returnMessage;
   return returnMessage;
}

Remarks

If the ctorMsg parameter is null, then the InitializeServerObject method calls the parameterless constructor for the new instance of the remote object that is represented by the current RealProxy.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1