RealProxy.InitializeServerObject(IConstructionCallMessage) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
用指定的 Type 初始化 RealProxy 的当前实例所表示的远程对象的对象 IConstructionCallMessage 的新实例。
public:
System::Runtime::Remoting::Activation::IConstructionReturnMessage ^ InitializeServerObject(System::Runtime::Remoting::Activation::IConstructionCallMessage ^ ctorMsg);
public System.Runtime.Remoting.Activation.IConstructionReturnMessage InitializeServerObject (System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg);
[System.Runtime.InteropServices.ComVisible(true)]
public System.Runtime.Remoting.Activation.IConstructionReturnMessage InitializeServerObject (System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg);
[System.Runtime.InteropServices.ComVisible(true)]
[System.Security.SecurityCritical]
public System.Runtime.Remoting.Activation.IConstructionReturnMessage InitializeServerObject (System.Runtime.Remoting.Activation.IConstructionCallMessage ctorMsg);
member this.InitializeServerObject : System.Runtime.Remoting.Activation.IConstructionCallMessage -> System.Runtime.Remoting.Activation.IConstructionReturnMessage
[<System.Runtime.InteropServices.ComVisible(true)>]
member this.InitializeServerObject : System.Runtime.Remoting.Activation.IConstructionCallMessage -> System.Runtime.Remoting.Activation.IConstructionReturnMessage
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Security.SecurityCritical>]
member this.InitializeServerObject : System.Runtime.Remoting.Activation.IConstructionCallMessage -> System.Runtime.Remoting.Activation.IConstructionReturnMessage
Public Function InitializeServerObject (ctorMsg As IConstructionCallMessage) As IConstructionReturnMessage
参数
- ctorMsg
- IConstructionCallMessage
构造调用消息,它包含当前 RealProxy 所表示的远程对象的新实例的构造函数参数。 可以为 null
。
返回
构造请求的结果。
- 属性
例外
直接调用方没有 UnmanagedCode 权限。
示例
virtual IMessage^ Invoke( IMessage^ myMessage ) override
{
Console::WriteLine( "MyProxy 'Invoke method' Called..." );
if ( dynamic_cast<IMethodCallMessage^>(myMessage) )
{
Console::WriteLine( "IMethodCallMessage*" );
}
if ( dynamic_cast<IMethodReturnMessage^>(myMessage) )
{
Console::WriteLine( "IMethodReturnMessage*" );
}
if ( dynamic_cast<IConstructionCallMessage^>(myMessage) )
{
// Initialize a new instance of remote object
IConstructionReturnMessage^ myIConstructionReturnMessage = this->InitializeServerObject( static_cast<IConstructionCallMessage^>(myMessage) );
ConstructionResponse^ constructionResponse = gcnew ConstructionResponse( nullptr,static_cast<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 = dynamic_cast<IMethodReturnMessage^>(returnMessage);
return returnMessage;
}
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;
}
Public Overrides Function Invoke(myMessage As IMessage) As IMessage
Console.WriteLine("MyProxy 'Invoke method' Called...")
If TypeOf myMessage Is IMethodCallMessage Then
Console.WriteLine("IMethodCallMessage")
End If
If TypeOf myMessage Is IMethodReturnMessage Then
Console.WriteLine("IMethodReturnMessage")
End If
If TypeOf myMessage Is IConstructionCallMessage Then
' Initialize a new instance of remote object
Dim myIConstructionReturnMessage As IConstructionReturnMessage = _
Me.InitializeServerObject(CType(myMessage, IConstructionCallMessage))
Dim constructionResponse As _
New ConstructionResponse(Nothing, CType(myMessage, IMethodCallMessage))
Return constructionResponse
End If
Dim myIDictionary As IDictionary = myMessage.Properties
Dim returnMessage As IMessage
myIDictionary("__Uri") = myUri
' Synchronously dispatch messages to server.
returnMessage = ChannelServices.SyncDispatchMessage(myMessage)
' Pushing return value and OUT parameters back onto stack.
Dim myMethodReturnMessage As IMethodReturnMessage = _
CType(returnMessage, IMethodReturnMessage)
Return returnMessage
End Function 'Invoke
注解
如果参数 ctorMsg
为 null
,则 InitializeServerObject 该方法为当前 RealProxy表示的远程对象的新实例调用无参数构造函数。