views:

108

answers:

1

In middle of application when calling following line:

var component = _Kernel.Get<IComponent>();

I'm getting TargetInvocationException. IComponent is a Form.

at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.ConstructorInfo.Invoke(Object[] parameters) at Ninject.Injection.ReflectionInjectorFactory.<>c_DisplayClass1.b_0(Object[] args) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.Resolve()
at Ninject.KernelBase.b_7(IContext context) at System.Linq.Enumerable.d_d2.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source) at Ninject.Planning.Targets.Target1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) at Ninject.Activation.Providers.StandardProvider.<>c__DisplayClass2.<Create>b__1(ITarget target) at System.Linq.Enumerable.<SelectIterator>d__d2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.Resolve()
at Ninject.KernelBase.<Resolve>b__7(IContext context) at System.Linq.Enumerable.<SelectIterator>d__d
2.MoveNext() at System.Linq.Enumerable.d__b01.MoveNext() at System.Linq.Enumerable.Single[TSource](IEnumerable1 source) at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters)

A: 

When asking for help, you need to give some context. There is a lot going on and if you don't give any context, it is nearly impossible to help. Give a reproduction scenario, or a small piece of the object being created. Was it an internal class, protected .ctor, etc. The more information you give the easier it is to help.

Ian Davis