我是Ninject的新手,我看到了一个例外,不知道该怎么做。有人可以帮忙: -
Object reference not set to an instance of an object.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
System.Object.GetType() +0
Ninject.Core.Creation.Providers.InjectionProviderBase.GetValueFromInlineArgument(IContext context, ITarget target) in \Ninject\src\Core\Creation\Providers\InjectionProviderBase.cs:139
Ninject.Core.Creation.Providers.InjectionProviderBase.ResolveConstructorArguments(IContext context, ConstructorInjectionDirective directive) in \Ninject\src\Core\Creation\Providers\InjectionProviderBase.cs:109
Ninject.Core.Creation.Providers.InjectionProviderBase.CallInjectionConstructor(IContext context) in \Ninject\src\Core\Creation\Providers\InjectionProviderBase.cs:79
Ninject.Core.Creation.Providers.InjectionProviderBase.Create(IContext context) in \Ninject\src\Core\Creation\Providers\InjectionProviderBase.cs:60
Ninject.Core.Activation.ActivatorBase.Create(IContext context, Object& instance) in \Ninject\src\Core\Activation\ActivatorBase.cs:114
Ninject.Core.Behavior.BehaviorBase.CreateInstance(IContext context, Object& instance) in \Ninject\src\Core\Behavior\BehaviorBase.cs:102
Ninject.Core.Behavior.TransientBehavior.Resolve(IContext context) in \Ninject\src\Core\Behavior\TransientBehavior.cs:55
Ninject.Core.KernelBase.ResolveInstance(Type service, IContext context, Boolean isEagerActivation) in \Ninject\src\Core\KernelBase.cs:566
Ninject.Core.KernelBase.Get(Type type, IContext context) in \Ninject\src\Core\KernelBase.cs:278
Ninject.Core.Resolution.Resolvers.StandardResolver.ResolveInstance(IContext outerContext, IContext innerContext) in \Ninject\src\Core\Resolution\Resolvers\StandardResolver.cs:54
Ninject.Core.Resolution.Resolvers.ResolverBase.Resolve(IContext outerContext, IContext innerContext) in \Ninject\src\Core\Resolution\Resolvers\ResolverBase.cs:80
Ninject.Core.Creation.Providers.InjectionProviderBase.ResolveConstructorArguments(IContext context, ConstructorInjectionDirective directive) in \Ninject\src\Core\Creation\Providers\InjectionProviderBase.cs:119
Ninject.Core.Creation.Providers.InjectionProviderBase.CallInjectionConstructor(IContext context) in \Ninject\src\Core\Creation\Providers\InjectionProviderBase.cs:79
Ninject.Core.Creation.Providers.InjectionProviderBase.Create(IContext context) in \Ninject\src\Core\Creation\Providers\InjectionProviderBase.cs:60
Ninject.Core.Activation.ActivatorBase.Create(IContext context, Object& instance) in \Ninject\src\Core\Activation\ActivatorBase.cs:114
Ninject.Core.Behavior.BehaviorBase.CreateInstance(IContext context, Object& instance) in \Ninject\src\Core\Behavior\BehaviorBase.cs:102
Ninject.Core.Behavior.TransientBehavior.Resolve(IContext context) in \Ninject\src\Core\Behavior\TransientBehavior.cs:55
Ninject.Core.KernelBase.ResolveInstance(Type service, IContext context, Boolean isEagerActivation) in \Ninject\src\Core\KernelBase.cs:566
Ninject.Core.KernelBase.Get(Type type, IContext context) in \Ninject\src\Core\KernelBase.cs:278
Ninject.Core.Resolution.Resolvers.StandardResolver.ResolveInstance(IContext outerContext, IContext innerContext) in \Ninject\src\Core\Resolution\Resolvers\StandardResolver.cs:54
Ninject.Core.Resolution.Resolvers.ResolverBase.Resolve(IContext outerContext, IContext innerContext) in \Ninject\src\Core\Resolution\Resolvers\ResolverBase.cs:80
Ninject.Core.Activation.Strategies.FieldInjectionStrategy.Initialize(IContext context, Object& instance) in \Ninject\src\Core\Activation\Strategies\FieldInjectionStrategy.cs:59
Ninject.Core.Activation.ActivatorBase.Create(IContext context, Object& instance) in \Ninject\src\Core\Activation\ActivatorBase.cs:130
Ninject.Core.KernelBase.InjectExistingObject(Object instance) in \Ninject\src\Core\KernelBase.cs:599
Ninject.Core.KernelBase.Inject(Object instance) in \Ninject\src\Core\KernelBase.cs:288
Ninject.Framework.Web.KernelContainer.Inject(Object instance) in \Ninject\src\Framework\Web\KernelContainer.cs:69
Ninject.Framework.Web.UserControlBase.RequestActivation() in \Ninject\src\Framework\Web\UserControlBase.cs:41
Ninject.Framework.Web.UserControlBase.OnInit(EventArgs e) in \Ninject\src\Framework\Web\UserControlBase.cs:33
System.Web.UI.Control.InitRecursive(Control namingContainer) +143
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1477
答案 0 :(得分:2)
从堆栈跟踪中我可以看到你正在使用一些Ninject 1.x.x版本。当前版本是2.2.1,您可以从nuget安装3.0.0版本的候选版本。 Ninject 1不再维护。
我建议更新为2.2.1或3.0.0。否则你将不得不从github获取源代码并自己调试问题并提供拉取请求来解决问题。
答案 1 :(得分:0)
我有类似的问题。在我的情况下,我使用Nuget on Mono的Ninject 3.2.2.0软件包,不得不回滚到3.2.0.0,正如我从this ticket on the Ninject issue tracker发现的那样。看起来Ninject通过反射在.Net中使用了未发布的API,而这在Mono中并不存在。