I have this class:
I then call this Func1() using reflection.Code:public class Class1 { public Class(){} public Func1() { try { int x = Convert.ToInt32("a"); } catch(Exception ex) { throw ex; } } }
When the exception occurs inside Func1(), I throw that exception so it's caught by the next "catch". Why is the exception that is caught outside the Invoke() method not the same exception that I threw? Instead it catches an invoke method exception. Is there a way for it to catch the same exception I threw inside the Func1()?Code:try { //some code that allows me to call method through reflection //mi is MethodInfo object and obj is an instance of Class1 mi.Invoke(obj, null); } catch(Exception) { MessageBox.Show(ex.Message); }




Reply With Quote