How to get the current exception without having passing the variable?

后端 未结 2 1824
死守一世寂寞
死守一世寂寞 2021-01-17 16:19

I am looking for a way to retrieve the current exception without having to pass it as a variable.

Suppose the following code

public void MakeItFail()         


        
相关标签:
2条回答
  • 2021-01-17 16:57

    Try subscribing to this event when you first load your app.

    AppDomain.CurrentDomain.FirstChanceException += (s, e) =>
    {
        ShowMessage(e.Exception.Message);
    };
    
    0 讨论(0)
  • 2021-01-17 17:10

    No, there isn't.

    You need to use a parameter.

    0 讨论(0)
提交回复
热议问题