clairernovotny / ninject

the ninja of .net dependency injectors
http://ninject.org/
Other
26 stars 5 forks source link

Xamarin Android 6.0 & ios 9.2 Binding String Crash #6

Open EmmanueleVilla opened 8 years ago

EmmanueleVilla commented 8 years ago

Hi! I'm using the ninject portable nuget package (3.3.1) in my xamarin application and after updating xamarin yesterday, there is a strange error while injecting strings.

My Module code:

Bind<string> ().ToConstant ("value").Named ("key");

My Class Injection:

[Inject]
[Named("key")]
public string key { private get; set; }

The error is:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.ArgumentNullException: Cannot be null
[MonoDroid] Parameter name: member
[MonoDroid]   at Ninject.Infrastructure.Ensure.ArgumentNotNull (System.Object argument, System.String name) [0x00003] in <filename unknown>:0 
[MonoDroid]   at Ninject.Selection.Heuristics.StandardInjectionHeuristic.ShouldInject (System.Reflection.MemberInfo member) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Ninject.Selection.Selector+<>c__DisplayClass3.<SelectPropertiesForInjection>b__2 (IInjectionHeuristic h) [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Linq.Enumerable.Any[TSource] (IEnumerable`1 source, System.Func`2 predicate) [0x00035] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:1177 
[MonoDroid]   at Ninject.Selection.Selector.<SelectPropertiesForInjection>b__1 (System.Reflection.PropertyInfo p) [0x00013] in <filename unknown>:0 
[MonoDroid]   at System.Linq.Enumerable+WhereEnumerableIterator`1[TSource].MoveNext () [0x00048] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:149 
[MonoDroid]   at System.Collections.Generic.List`1[T].InsertRange (Int32 index, IEnumerable`1 collection) [0x000ff] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:788 
[MonoDroid]   at System.Collections.Generic.List`1[T].AddRange (IEnumerable`1 collection) [0x00000] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:276 
[MonoDroid]   at Ninject.Selection.Selector.SelectPropertiesForInjection (System.Type type) [0x00040] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Strategies.PropertyReflectionStrategy.Execute (IPlan plan) [0x00017] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Planner+<>c__DisplayClass1.<CreateNewPlan>b__0 (IPlanningStrategy s) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[T] (IEnumerable`1 series, System.Action`1 action) [0x00010] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Planner.CreateNewPlan (System.Type type) [0x00055] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Planner.GetPlan (System.Type type) [0x00027] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Context.ResolveInternal (System.Object scope) [0x000c9] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Context.Resolve () [0x0003a] in <filename unknown>:0 
[MonoDroid]   at Ninject.KernelBase.Resolve (IRequest request, Boolean handleMissingBindings) [0x00160] in <filename unknown>:0 
[MonoDroid]   at Ninject.KernelBase.Resolve (IRequest request) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Targets.Target`1[T].GetValue (System.Type service, IContext parent) [0x00032] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Targets.Target`1[T].ResolveWithin (IContext parent) [0x000d6] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Providers.StandardProvider.GetValue (IContext context, ITarget target) [0x0005e] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Providers.StandardProvider+<>c__DisplayClass5.<Create>b__2 (ITarget target) [0x00000] in <filename unknown>:0 
[MonoDroid]   at System.Linq.Enumerable+WhereSelectArrayIterator`2[TSource,TResult].MoveNext () [0x0004d] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:327 
[MonoDroid]   at System.Linq.Buffer`1[TElement]..ctor (IEnumerable`1 source) [0x00083] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:2570 
[MonoDroid]   at System.Linq.Enumerable.ToArray[TSource] (IEnumerable`1 source) [0x00011] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:830 
[MonoDroid]   at Ninject.Activation.Providers.StandardProvider.Create (IContext context) [0x00129] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Context.ResolveInternal (System.Object scope) [0x00035] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Context.Resolve () [0x0003a] in <filename unknown>:0 
[MonoDroid]   at Ninject.KernelBase.Resolve (IRequest request, Boolean handleMissingBindings) [0x00160] in <filename unknown>:0 
[MonoDroid]   at Ninject.KernelBase.Resolve (IRequest request) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Targets.Target`1[T].GetValue (System.Type service, IContext parent) [0x00032] in <filename unknown>:0 
[MonoDroid]   at Ninject.Planning.Targets.Target`1[T].ResolveWithin (IContext parent) [0x000d6] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Strategies.PropertyInjectionStrategy.GetValue (IContext context, ITarget target, IEnumerable`1 allPropertyValues) [0x0003e] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Strategies.PropertyInjectionStrategy.Activate (IContext context, Ninject.Activation.InstanceReference reference) [0x00049] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Pipeline+<>c__DisplayClass2.<Activate>b__0 (IActivationStrategy s) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[T] (IEnumerable`1 series, System.Action`1 action) [0x00010] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Pipeline.Activate (IContext context, Ninject.Activation.InstanceReference reference) [0x00044] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Context.ResolveInternal (System.Object scope) [0x000d9] in <filename unknown>:0 
[MonoDroid]   at Ninject.Activation.Context.Resolve () [0x0004e] in <filename unknown>:0 
[MonoDroid]   at Ninject.KernelBase.Resolve (IRequest request, Boolean handleMissingBindings) [0x00160] in <filename unknown>:0 
[MonoDroid]   at Ninject.KernelBase.Resolve (IRequest request, Boolean handleMissingBindings) [0x00063] in <filename unknown>:0 
[MonoDroid]   at Ninject.KernelBase.Resolve (IRequest request) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Ninject.ResolutionExtensions.GetResolutionIterator (IResolutionRoot root, System.Type service, System.Func`2 constraint, IEnumerable`1 parameters, Boolean isOptional, Boolean isUnique) [0x0002f] in <filename unknown>:0 
[MonoDroid]   at Ninject.ResolutionExtensions.Get[T] (IResolutionRoot root, Ninject.Parameters.IParameter[] parameters) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Atlas.Droid.Framework.AVMApplication`1[T].BuildViewModel () [0x0000d] in /Users/emmanuelevilla/atlas/Atlas.Droid/Framework/AVMApplication.cs:24 

In the same module I have others string bindings and all of them crashes while injecting.

Things I've tried:

I've tried to download this repository and in the android test project it works, but I suppose that the nuGet package is older because the repository project shows me some warnings of deprecated classes, like StandardKernel, when I try to use them.

Thanks and don't hesitate if you want me to do some other tests!

Andrewkk commented 8 years ago

I have exactly the same issue. All other exports appear to work fine it's just the Named Strings I need to upgrade my Xamarin projects but this is blocking me. I would really appreciate some indication of when this may be resolved so that I can make a decision on if I have to implement a work around or I can wait for the fix? Thanks

Florismart commented 8 years ago

Hi Andrewkk, me and EmanueleVilla work together. Waiting for a fix, after many hours spent,we just decided tu use public constant strings.. or, for particular situations, we used properties in a singleton class initialized at app start

ONLY FOR STRINGs!

I hope this help you

Andrewkk commented 8 years ago

Hi Thanks for the advice I may end up doing the same. I did pull the source from Github and build a debug version in the hope that I could find the problem and suggest a fix. However the debug version didn't crash! The problem must have been fixed already in the source code since the last stable released version (3.3.1). So I really would like to know when I can expect a release please. Thanks

chetuanu commented 8 years ago

Guys how to update my phone to android y

chetuanu commented 8 years ago

Android 6