我从 nuget 包管理器安装了 MVC3,一切似乎都可以编译,但是当我尝试运行我的应用程序时,我得到以下信息:
System.TypeLoadException was unhandled by user code
HResult=-2146233054
Message=Inheritance security rules violated by type: 'Ninject.Web.Mvc.Filter.FilterContextParameter'. Derived types must either match the security accessibility of the base type or be less accessible.
Source=mscorlib
TypeName=Ninject.Web.Mvc.Filter.FilterContextParameter
StackTrace:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Ninject.Infrastructure.Language.ExtensionsForAssembly.HasNinjectModules(Assembly assembly) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForAssembly.cs:line 25
at Ninject.Modules.CompiledModuleLoaderPlugin.<LoadModules>b__0(Assembly asm) in c:\Projects\Ninject\ninject\src\Ninject\Modules\CompiledModuleLoaderPlugin.cs:line 81
at Ninject.Modules.AssemblyNameRetriever.AssemblyChecker.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter) in c:\Projects\Ninject\ninject\src\Ninject\Modules\AssemblyNameRetriever.cs:line 114
at Ninject.Modules.AssemblyNameRetriever.AssemblyChecker.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter)
at Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter) in c:\Projects\Ninject\ninject\src\Ninject\Modules\AssemblyNameRetriever.cs:line 54
at Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable`1 filenames) in c:\Projects\Ninject\ninject\src\Ninject\Modules\CompiledModuleLoaderPlugin.cs:line 81
at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable`1 patterns) in c:\Projects\Ninject\ninject\src\Ninject\Modules\ModuleLoader.cs:line 60
at Ninject.KernelBase.Load(IEnumerable`1 filePatterns) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 236
at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 97
at Ninject.KernelBase..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 57
at Ninject.StandardKernel..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\StandardKernel.cs:line 46
at HoneyBadger.Web.Mvc.App_Start.NinjectWebCommon.CreateKernel() in c:\HoneyBadger\trunk\HoneyBadger.Web.Mvc\HoneyBadger.Web.Mvc\App_Start\NinjectWebCommon.cs:line 43
at Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:line 50
at HoneyBadger.Web.Mvc.App_Start.NinjectWebCommon.Start() in c:\HoneyBadger\trunk\HoneyBadger.Web.Mvc\HoneyBadger.Web.Mvc\App_Start\NinjectWebCommon.cs:line 26
InnerException:
有任何想法吗??
更新:
我还想补充一点,它正在轰炸新的 StandardKernel()
private static IKernel CreateKernel()
{
var kernel = new StandardKernel();
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
RegisterServices(kernel);
return kernel;
}
添加 AllowPartiallyTrustedCallers 后出现新错误:
Attempt by security transparent method 'HoneyBadger.Web.Mvc.App_Start.NinjectWebCommon..cctor()' to access security critical method 'Ninject.Web.Common.Bootstrapper..ctor()' failed.
Assembly 'HoneyBadger.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.