-
-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Labels
masterIssue has been merged into ‘master’Issue has been merged into ‘master’
Milestone
Description
Hello,
I have some code which used Unity 5.8.6. When a resolution of a class failed, it used to throw a Unity.Exceptions.ResolutionFailedException.
In Unity 5.11.1, it throws a System.Reflection.TargetInvocationException now. Is this a design decision or a bug?
Example:
The following code registers a class, which throws an exception in the constructor:
using System.Reflection;
using Unity;
namespace UnityNewException
{
class Program
{
static void Main(string[] args)
{
UnityContainer container = new UnityContainer();
container.RegisterType<ITestClass, TestClass>();
try
{
// The implementation should throw an exception in the constructor.
var config = container.Resolve<ITestClass>();
}
// Thrown in Unity 5.8.6
catch (ResolutionFailedException e)
{
System.Console.WriteLine("Exception = " + e.GetType());
System.Console.WriteLine("Inner exception = " + e.InnerException.GetType());
}
// Thrown in Unity 5.11.1
catch (TargetInvocationException e)
{
System.Console.WriteLine("Exception = " + e.GetType());
System.Console.WriteLine("Inner exception = " + e.InnerException.GetType());
}
System.Console.ReadKey();
}
}
}
Is there any difference between ResolutionFailedException and TargetInvocationException? Is ResolutionFailedException outdated or is this a bug?
Thanks.
Metadata
Metadata
Assignees
Labels
masterIssue has been merged into ‘master’Issue has been merged into ‘master’