Why is custom exception changed to System.Exception when method invoked via method.invoke()?
<p>I've written a custom exception AbortTestException, which is pretty simple:</p>

<pre><code>class AbortTestException : Exception
{
    public AbortTestException(string message) 
        : base(message) { }
}
</code></pre>

<p>Then I have a function that will throw it:</p>

<pre><code>class Foo
{
    public void Throws()
    {
        throw new AbortTestException("hi");
    }
}
</code></pre>

<p>And Throws() gets called via method reference:</p>

<pre><code>class Program
{
    static void Main(string[] args)
    {
        Type myType = (typeof(Foo));
        var method = myType.GetMethod("Throws");
        try
        {
            method.Invoke(new Foo(), null);
        }
        catch (AbortTestException ex)
        {
            Console.WriteLine("AbortTestException");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Exception");
        }
    }
}
</code></pre>

<p>However, something weird happens. Even though Throws rises an AbortTestException, the catch(Exception) block gets used (instead of the catch(AbortTestException) block). I tried putting the "throw new AbortTestException("hi")" portion in the try block itself, and verified that the correct catch block is used.</p>

<p>Is there some reason an exception would be re-cast when emitted via MethodInfo.invoke()?</p>
