2012-08-06 70 views
4

我有一個mvc4 web應用程序。我決定使用ninject.mvc3。所以我從nuget安裝它。但它拋出了這個異常:ninject mvc4中違反了類型:'Ninject.Web.Mvc.Filter.FilterContextParameter'的繼承安全規則

繼承安全規則違反類型:'Ninject.Web.Mvc.Filter.FilterContextParameter'。派生類型必須 或者匹配基類型的安全可訪問性,或者可以小於 。

private static IKernel CreateKernel() 
     { 
      var kernel = new StandardKernel(); //Throws exception this line 
      kernel.Bind<Func<IKernel>>().ToMethod(ctx =>() => new Bootstrapper().Kernel); 
      kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); 
      return kernel; 
     } 

任何想法是什麼原因造成的?

回答

0

如果您通過引用System.Web.Security命名空間將以下行添加到AssemblyInfo.cs文件中,可能會有所幫助。

[assembly: AllowPartiallyTrustedCallers()]