I have this code which Invokes a MethodInfo:
try
{
registrator.Method.Invoke(instance, parameters);
}
catch{
registrator.FailureType = RegistratorFailureType.ExceptionInRegistrator;
//registrator.Exception = e;
}
The Registrator is just a MethodInfo wrapper, the Method property is the MethodInfo object itself. parameters is and object[] and instance is a correct instance of the Method’s declaring type (created with Activator.Create).
The Method looks like this (I was testing exception catching):
class Test : Plugin, ITest
{
public void Register(IWindow window)
{
throw new Exception("Hooah");
}
}
The problem is: The exception is never caught and the Visual Studio’s uncaught exception bubble pops up.
This is in VS 2010 with .NET 4.0
The problem is not in your code anyway.
In the Debug/Exceptions menu, remove all checks.
It should work.