2

重複の可能性:
Ninject モデル バリデーターが中程度の信頼で問題を引き起こしている

他の情報源に従って CreateKernel を変更しました:

    private static IKernel CreateKernel()
    {
        var kernel = new StandardKernel(new NinjectSettings { UseReflectionBasedInjection = true });
        RegisterServices(kernel);
        return kernel;
    }

それでも私は得る:

System.Security.SecurityException was unhandled by user code
  Message=Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
  Source=mscorlib
  StackTrace:
       at System.Security.CodeAccessSecurityEngine.SpecialDemand(PermissionType whatPermission, StackCrawlMark& stackMark)
       at System.Security.CodeAccessPermission.Demand(PermissionType permissionType)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition(MethodInfo method, BindingFlags flags) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForMemberInfo.cs:line 145
       at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition(PropertyInfo property) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForMemberInfo.cs:line 126
       at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.IsDefined(PropertyInfo element, Type attributeType, Boolean inherit) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForMemberInfo.cs:line 162
       at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute(MemberInfo member, Type type) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForMemberInfo.cs:line 50
       at Ninject.Selection.Heuristics.StandardInjectionHeuristic.ShouldInject(MemberInfo member) in c:\Projects\Ninject\ninject\src\Ninject\Selection\Heuristics\StandardInjectionHeuristic.cs:line 47
       at Ninject.Selection.Selector.<>c__DisplayClass3.<SelectPropertiesForInjection>b__2(IInjectionHeuristic h) in c:\Projects\Ninject\ninject\src\Ninject\Selection\Selector.cs:line 92
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
       at Ninject.Selection.Selector.<SelectPropertiesForInjection>b__1(PropertyInfo p) in c:\Projects\Ninject\ninject\src\Ninject\Selection\Selector.cs:line 92
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
       at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
       at Ninject.Selection.Selector.SelectPropertiesForInjection(Type type) in c:\Projects\Ninject\ninject\src\Ninject\Selection\Selector.cs:line 89
       at Ninject.Planning.Strategies.PropertyReflectionStrategy.Execute(IPlan plan) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Strategies\PropertyReflectionStrategy.cs:line 60
       at Ninject.Planning.Planner.<>c__DisplayClass3.<GetPlan>b__1(IPlanningStrategy s) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Planner.cs:line 68
       at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[T](IEnumerable`1 series, Action`1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:line 23
       at Ninject.Planning.Planner.GetPlan(Type type) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Planner.cs:line 68
       at Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\ninject\src\Ninject\Activation\Context.cs:line 180
       at Ninject.KernelBase.<Resolve>b__7(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 375
       at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
       at Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Targets\Target.cs:line 179
       at Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Targets\Target.cs:line 147
       at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:line 97
       at Ninject.Activation.Providers.StandardProvider.<>c__DisplayClass2.<Create>b__1(ITarget target) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:line 81
       at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:line 81
       at Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\ninject\src\Ninject\Activation\Context.cs:line 157
       at Ninject.KernelBase.<Resolve>b__7(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 375
       at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.<CastIterator>d__b1`1.MoveNext()
       at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
       at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:line 37
       at Ninject.Web.Mvc.Bootstrapper.CreateDependencyResolver() in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\Bootstrapper.cs:line 92
       at Ninject.Web.Mvc.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\Bootstrapper.cs:line 68
       at Whatever.App_Start.NinjectMVC3.Start() in D:\Whatever\App_Start\NinjectMVC3.cs:line 26
  InnerException:

何か案は?

4

0 に答える 0