title: Exception has been thrown by the target of an invocation (MethodBase.Invoke Method)
body: <p>I want to catch the exceptions that are thrown in methods called with invoke method. </p>
  
  <pre><code>public void TestMethod()
  {
     try     
     {
         method.Invoke(commandHandler, new[] { newCommand });
     }
     catch(Exception e)
     {     
         ExceptionService.SendException(e);
     }
  }
  </code></pre>
  
  <p>method.Invoke calls the following method:</p>
  
  <pre><code>public void Register(/*parameters*/)
  {
       if(test_condition())
            throw new CustomException("Exception Message");
  }
  </code></pre>
  
  <p>The problem is that when I catch the CustomException, in the TestMethod, the e variable on the catch statement has NOT the type CustomException. It has the following message: "Exception has been thrown by the target of an invocation".</p>
  
  <p>I want to catch the exception that has been raised (which is CustomException), and pass it to the ExceptionService mechanism. </p>
  
  <p>What am I doing wrong?</p>