Я искал другие релевантные сообщения, но ничего не нашел, так что вот так ...
У меня есть (супер) простой тест Ninject, который не проходит с NullReferenceExcption, и я могуне могу найти информацию о том, почему.Это происходит, если в интерфейсе определен упрощенный метод доступа к свойствам C #, иначе все в порядке.Если я уберу get;задавать;функциональность работает как положено.
Мой вопрос: я просто делаю что-то, что не должно работать - например, связано ли это с устаревшей функциональностью внедрения поля?
Весь (неудачный) примерочень коротко:
using System;
using Ninject;
namespace NinjectIFPropError
{
public interface IDummy
{
int Number {get;set;}
void Doit();
}
public class DummyClass : IDummy
{
public int Number {get;set;}
public void Doit()
{
Console.WriteLine("Doit");
}
}
class Program
{
public static void Main (string[] args)
{
IKernel kernel = new StandardKernel();
kernel.Bind<IDummy>().To<DummyClass>();
IDummy id = kernel.Get<IDummy>();
id.Doit();
}
}
}
Я использую установленную по умолчанию версию Mono 2.10.5 на Ubuntu 11.10.Ninject v2.2.1.0 для .Net 4.0, загруженный с Ninject.org.
Любая информация будет оценена.а также (довольно долго):
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition (System.Reflection.MethodInfo method, BindingFlags flags) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition (System.Reflection.PropertyInfo property) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.IsDefined (System.Reflection.PropertyInfo element, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute (System.Reflection.MemberInfo member, System.Type type) [0x00000] in <filename unknown>:0
at Ninject.Selection.Heuristics.StandardInjectionHeuristic.ShouldInject (System.Reflection.MemberInfo member) [0x00000] in <filename unknown>:0
at Ninject.Selection.Selector+<>c__DisplayClass3.<SelectPropertiesForInjection>b__2 (IInjectionHeuristic h) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Any[IInjectionHeuristic] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at Ninject.Selection.Selector.<SelectPropertiesForInjection>b__1 (System.Reflection.PropertyInfo p) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator35`1[System.Reflection.PropertyInfo].MoveNext () [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[System.Reflection.PropertyInfo].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[System.Reflection.PropertyInfo].AddRange (IEnumerable`1 collection) [0x00000] in <filename unknown>:0
at Ninject.Selection.Selector.SelectPropertiesForInjection (System.Type type) [0x00000] in <filename unknown>:0
at Ninject.Planning.Strategies.PropertyReflectionStrategy.Execute (IPlan plan) [0x00000] in <filename unknown>:0
at Ninject.Planning.Planner+<>c__DisplayClass3.<GetPlan>b__1 (IPlanningStrategy s) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[IPlanningStrategy] (IEnumerable`1 series, System.Action`1 action) [0x00000] in <filename unknown>:0
at Ninject.Planning.Planner.GetPlan (System.Type type) [0x00000] in <filename unknown>:0
at Ninject.Activation.Providers.StandardProvider.Create (IContext context) [0x00000] in <filename unknown>:0
at Ninject.Activation.Context.Resolve () [0x00000] in <filename unknown>:0
at Ninject.KernelBase.<Resolve>b__7 (IContext context) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator27`2[Ninject.Activation.IContext,System.Object].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateCastIterator>c__Iterator17`1[NinjectIFPropError.IDummy].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[IDummy] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[IDummy] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at Ninject.ResolutionExtensions.Get[IDummy] (IResolutionRoot root, Ninject.Parameters.IParameter[] parameters) [0x00000] in <filename unknown>:0
at NinjectIFPropError.Program.Main (System.String[] args) [0x00018] in /home/roger/Projects/NinjectIFPropError/Main.cs:38
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition (System.Reflection.MethodInfo method, BindingFlags flags) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition (System.Reflection.PropertyInfo property) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.IsDefined (System.Reflection.PropertyInfo element, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute (System.Reflection.MemberInfo member, System.Type type) [0x00000] in <filename unknown>:0
at Ninject.Selection.Heuristics.StandardInjectionHeuristic.ShouldInject (System.Reflection.MemberInfo member) [0x00000] in <filename unknown>:0
at Ninject.Selection.Selector+<>c__DisplayClass3.<SelectPropertiesForInjection>b__2 (IInjectionHeuristic h) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Any[IInjectionHeuristic] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at Ninject.Selection.Selector.<SelectPropertiesForInjection>b__1 (System.Reflection.PropertyInfo p) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator35`1[System.Reflection.PropertyInfo].MoveNext () [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[System.Reflection.PropertyInfo].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[System.Reflection.PropertyInfo].AddRange (IEnumerable`1 collection) [0x00000] in <filename unknown>:0
at Ninject.Selection.Selector.SelectPropertiesForInjection (System.Type type) [0x00000] in <filename unknown>:0
at Ninject.Planning.Strategies.PropertyReflectionStrategy.Execute (IPlan plan) [0x00000] in <filename unknown>:0
at Ninject.Planning.Planner+<>c__DisplayClass3.<GetPlan>b__1 (IPlanningStrategy s) [0x00000] in <filename unknown>:0
at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[IPlanningStrategy] (IEnumerable`1 series, System.Action`1 action) [0x00000] in <filename unknown>:0
at Ninject.Planning.Planner.GetPlan (System.Type type) [0x00000] in <filename unknown>:0
at Ninject.Activation.Providers.StandardProvider.Create (IContext context) [0x00000] in <filename unknown>:0
at Ninject.Activation.Context.Resolve () [0x00000] in <filename unknown>:0
at Ninject.KernelBase.<Resolve>b__7 (IContext context) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator27`2[Ninject.Activation.IContext,System.Object].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateCastIterator>c__Iterator17`1[NinjectIFPropError.IDummy].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[IDummy] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[IDummy] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at Ninject.ResolutionExtensions.Get[IDummy] (IResolutionRoot root, Ninject.Parameters.IParameter[] parameters) [0x00000] in <filename unknown>:0
at NinjectIFPropError.Program.Main (System.String[] args) [0x00018] in /home/roger/Projects/NinjectIFPropError/Main.cs:38