Export (0) Print
Expand All

MethodBase.GetCurrentMethod Method

Returns a MethodBase object representing the currently executing method.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public static MethodBase GetCurrentMethod ()
public static MethodBase GetCurrentMethod ()
public static function GetCurrentMethod () : MethodBase

Return Value

A MethodBase object representing the currently executing method.

using System;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Security.Permissions;

namespace RemotingSamples 
{
  [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.Infrastructure)]
  public class HelloServer : MarshalByRefObject 
  {
    [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.Infrastructure)]
    public HelloServer() 
    {
      Console.WriteLine("HelloServer activated");
    }

    [OneWay(), SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.Infrastructure)]
    public void HelloToServer(String name) 
    {
      Console.WriteLine("Hello.HelloToServer : {0}", name);
    }

    [SecurityPermission(SecurityAction.Demand, Flags=SecurityPermissionFlag.Infrastructure)]
    public String HelloToServerAndWait(String name)
    {
       Console.WriteLine("Client invoked HelloToServerAndWait : " + name);
       Console.WriteLine("Client waiting for return? {0}",
          RemotingServices.IsOneWay(MethodBase.GetCurrentMethod()) ? "No" : "Yes");
       return "Hi there, " + name;
    }
  }
}

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

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft