I have this code which Invokes a MethodInfo:
try
{
registrator.Method.Invoke(instance, parameters);
}
catch{
registrator.FailureType = RegistratorFa
The problem is not with the code you're showing.
I tried this:
void Main()
{
Test instance = new Test();
object[] parameters = new object[] { null };
MethodInfo method = typeof(Test).GetMethod("Register");
try
{
method.Invoke(instance, parameters);
}
catch
{
Console.Out.WriteLine("Exception");
}
}
interface ITest { }
interface IWindow { }
class Plugin { }
class Test : Plugin, ITest
{
public void Register(IWindow window)
{
throw new Exception("Hooah");
}
}
It printed "Exception" as expected. You need to show us more code.
If I modify the code like this:
catch(Exception ex)
{
Console.Out.WriteLine(ex.GetType().Name + ": " + ex.Message);
}
Then I get a TargetInvocationException, where the InnerException property is your thrown Exception.