I have Ninject configured to do DI in an ASP.NET MVC 3 application. This is working fine and it injects the proper classes in to my controllers.
When I try and add Ninject.Extensions.Interception to work with my application I start getting an ambiguous match exception. This only happens when I add the Ninject.Extensions.Interception.DynamicProxy assembly. If I remove this assembly then it runs fine again. I also have referenced Ninject.Extensions.Intereception and Castle.Core.
Note that I have not configured interception in the application. I am just adding a reference and this error starts happening.
I am using Ninject 2.2.1.0 and Ninject.Extensions.Interception 2.2.0.0.
private const BindingFlags DefaultBindingFlags =
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance;
public static PropertyInfo GetPropertyFromMethod( this MethodInfo method, Type implementingType )
{
if ( !method.IsSpecialName )
{
return null;
}
return implementingType.GetProperty( method.Name.Substring( 4 ), DefaultBindingFlags );
}
Stack trace:
[AmbiguousMatchException: Ambiguous match found.]
System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) +9402677 System.Type.GetProperty(String name, BindingFlags bindingAttr) +31
Ninject.Extensions.Interception.Infrastructure.Language.ExtensionsForMethodInfo.GetPropertyFromMethod(MethodInfo method, Type implementingType) in c:\Projects\Ninject\ninject.extensions.interception\src\Ninject.Extensions.Interception\Infrastructure\Language\ExtensionsForMethodInfo.cs:35 Ninject.Extensions.Interception.Planning.Strategies.InterceptorRegistrationStrategy.Execute(IPlan plan) in c:\Projects\Ninject\ninject.extensions.interception\src\Ninject.Extensions.Interception\Planning\Strategies\InterceptorRegistrationStrategy.cs:83 Ninject.Planning.<>c_DisplayClass3.b_1(IPlanningStrategy s) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Planner.cs:68 Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map(IEnumerable1 series, Action
1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:23 Ninject.Planning.Planner.GetPlan(Type type) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Planner.cs:68 Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:74 Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\ninject\src\Ninject\Activation\Context.cs:157 Ninject.KernelBase.b__7(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:375