How can I make Unity not to throw ResolutionFailedException if Resolve fails?
Is there something like TryResolve<IMyInterface>?
var container = new UnityContainer();
var foo = container.TryResolve<IFoo>();
Assert.IsNull(foo);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This has been an issue on the codeplex site, you can find the code here (look at the bottom of that thread and they have made an extension method…very handy)
http://unity.codeplex.com/Thread/View.aspx?ThreadId=24543
and the you can use code like this:
CanResolveis that extension method. I’m actually registering that extension upon creation of the container…something like this: