在我们的 MVC 项目中,我们广泛使用 Ninject。由于未知原因,StandardKernel 开始抛出 NotSupportedException 并显示消息“不支持具有 null 或空名称的模块”。这是代码:
var _kernel = new StandardKernel(); // <-- this line throws exception
_kernel.Bind<ISessionFactory>().ToMethod(x =>
{
// some code...
}).InSingletonScope();
_kernel.Bind<IAppDomainSetup>().To<AppDomainSetup>();
有人知道可能出了什么问题吗?谢谢。
PS这里是nuget config来查看程序集版本
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
<package id="Ninject.MVC3" version="3.0.0.6" targetFramework="net45" />
<package id="Ninject.Web.Common" version="3.0.0.7" targetFramework="net45" />
这是堆栈跟踪
at Ninject.KernelBase.Load(IEnumerable`1 m) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 207
at Ninject.KernelBase.Load(IEnumerable`1 assemblies) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:line 245
at Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable`1 filenames) in c:\Projects\Ninject\ninject\src\Ninject\Modules\CompiledModuleLoaderPlugin.cs:line 82
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 TradeNet.Web.MvcApplication.CreateKernel() in c:\Users\dpopiashvili.DEA\Documents\Visual Studio 2010\Projects\TradeNet\TradeNet.Web\Global.asax.cs:line 65
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 Ninject.Web.Common.NinjectHttpApplication.Application_Start() in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\NinjectHttpApplication.cs:line 80