Created
January 28, 2024 01:37
-
-
Save michaelviveiros/25e1235c4e5909748be6fc5d0496ad6f to your computer and use it in GitHub Desktop.
Obter o número da linha durante a exceção
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
//Seu código | |
} | |
catch (Exception ex) | |
{ | |
//Obtém o rastreamento da exceção com as informações do arquivo de origem. | |
var st = new StackTrace(ex, true); | |
//Obtenha o quadro da pilha superior. | |
var frame = st.GetFrame(0); | |
//Obtém o número da linha específica do stack frame. | |
var line = frame.GetFileLineNumber(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment