プロジェクトを MVC5 および Web API 2 にアップグレードしたところ、ASP.NET Web API の Ninject フィルター バインディングで次のエラーが発生しました。パッケージ Ninject.Web.WebApi-RC がインストールされています。これを修正する方法に関する解決策はありますか?
kernel.BindHttpFilter<ApiValidationFilter>(FilterScope.Action)
.WhenControllerHas<ApiValidationAttribute>();
kernel.BindHttpFilter<HttpHeaderFilter>(FilterScope.Controller)
.WhenControllerHas<HttpHeaderAttribute>()
.WithConstructorArgumentFromControllerAttribute<HttpHeaderAttribute>("name", q => q.Name)
.WithConstructorArgumentFromControllerAttribute<HttpHeaderAttribute>("value", q => q.Value);
ソース コード エラー:
public static IEnumerable<object> GetCustomAttributes(this HttpControllerDescriptor actionDescriptor, Type type)
{
return ((IEnumerable)typeof(HttpControllerDescriptor)
.GetMethod("GetCustomAttributes").MakeGenericMethod(type)
.Invoke(actionDescriptor, new object[0])).Cast<object>();
}
エラー
<Response>
<Message>An error has occurred.</Message>
<ExceptionMessage>Ambiguous match found.</ExceptionMessage>
<ExceptionType>System.Reflection.AmbiguousMatchException</ExceptionType>
<StackTrace>
at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) at System.Type.GetMethod(String name) at Ninject.Web.WebApi.FilterBindingSyntax.HttpActionDescriptorExtensionMethods.GetCustomAttributes(HttpControllerDescriptor actionDescriptor, Type type) in d:\Projects\Ninject.Web.WebApi\src\Ninject.Web.WebApi\FilterBindingSyntax\HttpActionDescriptorExtensionMethods.cs:line 54 at Ninject.Web.WebApi.FilterBindingSyntax.FilterFilterBindingBuilder`1.<>c__DisplayClass9.<WhenControllerHas>b__8(HttpConfiguration controllerContext, HttpActionDescriptor actionDescriptor) in d:\Projects\Ninject.Web.WebApi\src\Ninject.Web.WebApi\FilterBindingSyntax\FilterFilterBindingBuilder.cs:line 166 at Ninject.Web.WebApi.FilterBindingSyntax.FilterFilterBindingBuilder`1.<>c__DisplayClass2.<When>b__0(IRequest ctx) in d:\Projects\Ninject.Web.WebApi\src\Ninject.Web.WebApi\FilterBindingSyntax\FilterFilterBindingBuilder.cs:line 126 at Ninject.Planning.Bindings.BindingConfiguration.Matches(IRequest request) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Bindings\BindingConfiguration.cs:line 129 at Ninject.Planning.Bindings.Binding.Matches(IRequest request) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Bindings\Binding.cs:line 237 at Ninject.KernelBase.<>c__DisplayClass1c.<SatifiesRequest>b__1b(IBinding binding) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 455 at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) at Ninject.KernelBase.CanResolve(IRequest request) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 314 at Ninject.KernelBase.Resolve(IRequest request) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 345 at Ninject.ResolutionExtensions.GetResolutionIterator(IResolutionRoot root, Type service, Func`2 constraint, IEnumerable`1 parameters, Boolean isOptional, Boolean isUnique) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 263 at Ninject.ResolutionExtensions.GetAll[T](IResolutionRoot root, IParameter[] parameters) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 113 at Ninject.Web.WebApi.Filter.NinjectFilterProvider.GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor) in d:\Projects\Ninject.Web.WebApi\src\Ninject.Web.WebApi\Filter\NinjectFilterProvider.cs:line 57 at System.Web.Http.Controllers.HttpActionDescriptor.<InitializeFilterPipeline>b__0(IFilterProvider fp) at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.<ReverseIterator>d__a0`1.MoveNext() at System.Web.Http.Controllers.HttpActionDescriptor.<RemoveDuplicates>d__3.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.<ReverseIterator>d__a0`1.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at System.Web.Http.Controllers.HttpActionDescriptor.InitializeFilterPipeline() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at System.Web.Http.Controllers.HttpActionDescriptor.GetFilterPipeline() at System.Web.Http.Controllers.HttpActionDescriptor.GetFilterGrouping() at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()
</StackTrace>
</Response>