Compartilhar via


StackFrame.GetMethod Método

Definição

Obtém o método no qual o quadro está sendo executado.

public:
 System::Reflection::MethodBase ^ GetMethod();
public:
 virtual System::Reflection::MethodBase ^ GetMethod();
public System.Reflection.MethodBase GetMethod();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Metadata for the method might be incomplete or removed. Consider using DiagnosticMethodInfo.Create instead")]
public virtual System.Reflection.MethodBase? GetMethod();
public virtual System.Reflection.MethodBase? GetMethod();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Metadata for the method might be incomplete or removed")]
public virtual System.Reflection.MethodBase? GetMethod();
public virtual System.Reflection.MethodBase GetMethod();
member this.GetMethod : unit -> System.Reflection.MethodBase
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Metadata for the method might be incomplete or removed. Consider using DiagnosticMethodInfo.Create instead")>]
abstract member GetMethod : unit -> System.Reflection.MethodBase
override this.GetMethod : unit -> System.Reflection.MethodBase
abstract member GetMethod : unit -> System.Reflection.MethodBase
override this.GetMethod : unit -> System.Reflection.MethodBase
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Metadata for the method might be incomplete or removed")>]
abstract member GetMethod : unit -> System.Reflection.MethodBase
override this.GetMethod : unit -> System.Reflection.MethodBase
Public Function GetMethod () As MethodBase
Public Overridable Function GetMethod () As MethodBase

Retornos

O método no qual o quadro está sendo executado.

Atributos

Exemplos

O exemplo a seguir demonstra o uso do método GetMethod. Este exemplo de código faz parte de um exemplo maior fornecido para a StackFrame classe.

StackFrame fr = new StackFrame(1,true);
StackTrace st = new StackTrace(fr);
EventLog.WriteEntry(fr.GetMethod().Name,
                    st.ToString(),
                    EventLogEntryType.Warning);
Dim frame As New StackFrame(1, True)
Dim strace As New StackTrace(frame)            

EventLog.WriteEntry(frame.GetMethod().Name, _
                    strace.ToString(), _
                    EventLogEntryType.Warning)

Comentários

O método que está sendo executado no momento pode ser herdado de uma classe base, embora seja chamado em uma classe derivada. Nesse caso, a ReflectedType propriedade do MethodBase objeto que é retornado identifica GetMethod a classe base, não a classe derivada.

Aplica-se a