RemotingServices.ExecuteMessage 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 원격 개체에 연결한 다음, 제공된 IMethodCallMessage를 해당 개체에서 실행합니다.
public:
static System::Runtime::Remoting::Messaging::IMethodReturnMessage ^ ExecuteMessage(MarshalByRefObject ^ target, System::Runtime::Remoting::Messaging::IMethodCallMessage ^ reqMsg);
public static System.Runtime.Remoting.Messaging.IMethodReturnMessage ExecuteMessage (MarshalByRefObject target, System.Runtime.Remoting.Messaging.IMethodCallMessage reqMsg);
[System.Security.SecurityCritical]
public static System.Runtime.Remoting.Messaging.IMethodReturnMessage ExecuteMessage (MarshalByRefObject target, System.Runtime.Remoting.Messaging.IMethodCallMessage reqMsg);
static member ExecuteMessage : MarshalByRefObject * System.Runtime.Remoting.Messaging.IMethodCallMessage -> System.Runtime.Remoting.Messaging.IMethodReturnMessage
[<System.Security.SecurityCritical>]
static member ExecuteMessage : MarshalByRefObject * System.Runtime.Remoting.Messaging.IMethodCallMessage -> System.Runtime.Remoting.Messaging.IMethodReturnMessage
Public Shared Function ExecuteMessage (target As MarshalByRefObject, reqMsg As IMethodCallMessage) As IMethodReturnMessage
매개 변수
- target
- MarshalByRefObject
호출하려는 메서드가 들어 있는 원격 개체입니다.
- reqMsg
- IMethodCallMessage
지정된 원격 개체의 메서드에 대한 메서드 호출 메시지입니다.
반환
원격 메서드의 응답입니다.
- 특성
예외
직접 실행 호출자에 인프라 권한이 없는 경우
메서드가 개체의 기본 컨텍스트가 아닌 컨텍스트에서 호출된 경우
예제
다음 코드 예제를 사용 하는 방법에 설명 합니다 ExecuteMessage 원격 개체에 대 한 메서드 호출을 전달 하는 방법입니다.
[System::Security::Permissions::SecurityPermissionAttribute
(System::Security::Permissions::SecurityAction::LinkDemand,
Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)]
virtual void ProcessMessageStart( IMessage^ requestMessage, bool /*bClientSide*/, bool /*bAsyncCall*/ )
{
Console::WriteLine( "\nProcessMessageStart" );
Console::WriteLine( "requestMessage = {0}", requestMessage );
try
{
Console::WriteLine( "SessionId = {0}.", RemotingServices::GetSessionIdForMethodMessage( dynamic_cast<IMethodMessage^>(requestMessage) ) );
}
catch ( InvalidCastException^ )
{
Console::WriteLine( "The requestMessage is not an IMethodMessage*." );
}
IMethodCallMessage^ requestMethodCallMessage;
try
{
requestMethodCallMessage = dynamic_cast<IMethodCallMessage^>(requestMessage);
// Prints the details of the IMethodCallMessage* to the console.
Console::WriteLine( "\nMethodCall details" );
Console::WriteLine( "Uri = {0}", requestMethodCallMessage->Uri );
Console::WriteLine( "TypeName = {0}", requestMethodCallMessage->TypeName );
Console::WriteLine( "MethodName = {0}", requestMethodCallMessage->MethodName );
Console::WriteLine( "ArgCount = {0}", requestMethodCallMessage->ArgCount );
Console::WriteLine( "MethodCall::Args" );
IEnumerator^ myEnum = requestMethodCallMessage->Args->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ o = safe_cast<Object^>(myEnum->Current);
Console::WriteLine( "\t {0}", o );
// Sends this method call message to another server to replicate
// the call at the second server.
if ( requestMethodCallMessage->Uri == replicatedServiceUri )
{
String^ repSvr = String::Format( "{0}{1}", const_cast<String^>(replicationServerUrl), const_cast<String^>(replicatedServiceUri) );
SampleService^ replicationService = dynamic_cast<SampleService^>(Activator::GetObject( SampleService::typeid, repSvr ));
IMethodReturnMessage^ returnMessage = RemotingServices::ExecuteMessage( replicationService, requestMethodCallMessage );
// Prints the results of the method call stored in the IMethodReturnMessage*.
Console::WriteLine( "\nMessage returned by ExecuteMessage." );
Console::WriteLine( "\tException = {0}", returnMessage->Exception );
Console::WriteLine( "\tReturnValue = {0}", returnMessage->ReturnValue );
Console::WriteLine( "\tOutArgCount = {0}", returnMessage->OutArgCount );
Console::WriteLine( "Return message OutArgs" );
IEnumerator^ myEnum = requestMethodCallMessage->Args->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ o = safe_cast<Object^>(myEnum->Current);
Console::WriteLine( "\t {0}", o );
}
}
}
}
catch ( InvalidCastException^ )
{
Console::WriteLine( "The requestMessage is not a MethodCall" );
}
}
public void ProcessMessageStart(IMessage requestMessage, bool bClientSide, bool bAsyncCall) {
Console.WriteLine("\nProcessMessageStart");
Console.WriteLine("requestMessage = {0}", requestMessage);
try {
Console.WriteLine("SessionId = {0}.",
RemotingServices.GetSessionIdForMethodMessage((IMethodMessage)requestMessage));
}
catch (InvalidCastException) {
Console.WriteLine("The requestMessage is not an IMethodMessage.");
}
IMethodCallMessage requestMethodCallMessage;
try {
requestMethodCallMessage = (IMethodCallMessage)requestMessage;
// Prints the details of the IMethodCallMessage to the console.
Console.WriteLine("\nMethodCall details");
Console.WriteLine("Uri = {0}", requestMethodCallMessage.Uri);
Console.WriteLine("TypeName = {0}", requestMethodCallMessage.TypeName);
Console.WriteLine("MethodName = {0}", requestMethodCallMessage.MethodName);
Console.WriteLine("ArgCount = {0}", requestMethodCallMessage.ArgCount);
Console.WriteLine("MethodCall.Args");
foreach(object o in requestMethodCallMessage.Args)
Console.WriteLine("\t{0}", o);
// Sends this method call message to another server to replicate
// the call at the second server.
if (requestMethodCallMessage.Uri == replicatedServiceUri) {
SampleService replicationService =
(SampleService)Activator.GetObject(typeof(SampleService),
replicationServerUrl + replicatedServiceUri);
IMethodReturnMessage returnMessage =
RemotingServices.ExecuteMessage(replicationService, requestMethodCallMessage);
// Prints the results of the method call stored in the IMethodReturnMessage.
Console.WriteLine("\nMessage returned by ExecuteMessage.");
Console.WriteLine("\tException = {0}", returnMessage.Exception);
Console.WriteLine("\tReturnValue = {0}", returnMessage.ReturnValue);
Console.WriteLine("\tOutArgCount = {0}", returnMessage.OutArgCount);
Console.WriteLine("Return message OutArgs");
foreach(object o in requestMethodCallMessage.Args)
Console.WriteLine("\t{0}", o);
}
}
catch (InvalidCastException) {
Console.WriteLine("The requestMessage is not a MethodCall");
}
}
<SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
Public Sub ProcessMessageStart(requestMessage As IMessage, bClientSide As Boolean, bAsyncCall As Boolean) Implements IDynamicMessageSink.ProcessMessageStart
Console.WriteLine(ControlChars.Cr + "ProcessMessageStart")
Console.WriteLine("requestMessage = {0}", requestMessage)
Try
Console.WriteLine("SessionId = {0}.", RemotingServices.GetSessionIdForMethodMessage(CType(requestMessage, IMethodMessage)))
Catch e As InvalidCastException
Console.WriteLine("The requestMessage is not an IMethodMessage.")
End Try
Dim requestMethodCallMessage As IMethodCallMessage
Try
requestMethodCallMessage = CType(requestMessage, MethodCall)
' Prints the details of the IMethodCallMessage to the console
Console.WriteLine(ControlChars.Cr + "MethodCall details")
Console.WriteLine("Uri = {0}", requestMethodCallMessage.Uri)
Console.WriteLine("TypeName = {0}", requestMethodCallMessage.TypeName)
Console.WriteLine("MethodName = {0}", requestMethodCallMessage.MethodName)
Console.WriteLine("ArgCount = {0}", requestMethodCallMessage.ArgCount)
Console.WriteLine("MethodCall.Args")
Dim o As Object
For Each o In requestMethodCallMessage.Args
Console.WriteLine(ControlChars.Tab + "{0}", o)
Next o
' Sends this method call message to another server to replicate
' the call at the second server
If requestMethodCallMessage.Uri = replicatedServiceUri Then
Dim replicationService As SampleService = CType(Activator.GetObject(GetType(SampleService), replicationServerUrl + replicatedServiceUri), SampleService)
Dim returnMessage As IMethodReturnMessage = RemotingServices.ExecuteMessage(replicationService, requestMethodCallMessage)
' Prints the results of the method call stored in the IMethodReturnMessage.
Console.WriteLine(ControlChars.Cr + "Message returned by ExecuteMessage.")
Console.WriteLine(ControlChars.Tab + "Exception = {0}", returnMessage.Exception)
Console.WriteLine(ControlChars.Tab + "ReturnValue = {0}", returnMessage.ReturnValue)
Console.WriteLine(ControlChars.Tab + "OutArgCount = {0}", returnMessage.OutArgCount)
Console.WriteLine("Return message OutArgs")
For Each o In requestMethodCallMessage.Args
Console.WriteLine(ControlChars.Tab + "{0}", o)
Next o
End If
Catch e As InvalidCastException
Console.WriteLine("The requestMessage is not a MethodCall")
End Try
End Sub
설명
현재 메서드는 다른, 예: 원격 개체에 지정 된 메서드 호출을 전달 하는 서버에서 특별 한 경우에 사용 됩니다. 호출자가 적절 한 컨텍스트에 있는 경우에이 메서드를 호출할 수 있습니다.
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET