MethodBase.GetCurrentMethod-Methode
Gibt ein MethodBase-Objekt zurück, das die derzeit ausgeführte Methode darstellt.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared Function GetCurrentMethod As MethodBase
'Usage
Dim returnValue As MethodBase
returnValue = MethodBase.GetCurrentMethod
public static MethodBase GetCurrentMethod ()
public:
static MethodBase^ GetCurrentMethod ()
public static MethodBase GetCurrentMethod ()
public static function GetCurrentMethod () : MethodBase
Rückgabewert
Ein MethodBase-Objekt, das die derzeit ausgeführte Methode darstellt.
Beispiel
Imports System
Imports System.Reflection
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Messaging
Imports System.Security.Permissions
Namespace RemotingSamples
<SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.Infrastructure)> _
Public Class HelloServer
Inherits MarshalByRefObject
Public Sub New()
Console.WriteLine("HelloServer activated")
End Sub 'New
<OneWay(), SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.Infrastructure)> _
Public Sub HelloToServer(name As String)
Console.WriteLine("Hello.HelloToServer : {0}", name)
End Sub 'HelloToServer
<SecurityPermission(SecurityAction.Demand, Flags:=SecurityPermissionFlag.Infrastructure)> _
Public Function HelloToServerAndWait(name As String) As String
Console.WriteLine("Client invoked HelloToServerAndWait : " + name)
Console.WriteLine("Client waiting for return? {0}", _
IIf(RemotingServices.IsOneWay(MethodBase.GetCurrentMethod()),"No","Yes"))
Return "Hi there, " + name
End Function 'HelloToServerAndWait
End Class 'HelloServer
End Namespace 'RemotingSamples
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;
}
}
}
#using <system.dll>
#using <system.runtime.remoting.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Messaging;
using namespace System::Security::Permissions;
namespace RemotingSamples
{
public ref class HelloServer: public MarshalByRefObject
{
public:
HelloServer()
{
Console::WriteLine( "HelloServer activated" );
}
[OneWay]
void HelloToServer( String^ name )
{
Console::WriteLine( "Hello::HelloToServer : {0}", name );
}
[SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)]
String^ HelloToServerAndWait( String^ name )
{
Console::WriteLine( "Client invoked HelloToServerAndWait : {0}", name );
Console::WriteLine( "Client waiting for return? {0}", RemotingServices::IsOneWay( MethodBase::GetCurrentMethod() ) ? (String^)"No" : "Yes" );
return "Hi there, {0}",name;
}
};
}
.NET Framework-Sicherheit
- ReflectionPermission beim Laden mit später Bindung durch Mechanismen wie Type.InvokeMember. Zugeordnete Enumeration: ReflectionPermissionFlag.MemberAccess.
Plattformen
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
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
MethodBase-Klasse
MethodBase-Member
System.Reflection-Namespace