-
Notifications
You must be signed in to change notification settings - Fork 526
Closed
Description
This is my mono environment:
Mono JIT compiler version 2.10.5 (Debian 2.10.5-1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
My program targets .NET Framework 4.0 and was written on Windows using Visual Studio 2011, and I was using Ninject.3.0.0.15 provided by NuGet package manager.
And I have program below works well and outputs System.Net.WebProxy
class Program {
static void Main(string[] args) {
Console.Write(new WebProxy())
}
}
This should provide enough evident that I have the System.Net.WebProxy class in mono environment, but code below throws a NullReferenceException:
class Program {
static void Main(string[] args) {
IKernel kernel = new StandardKernel();
kernel.Bind<WebProxy>().ToSelf();
Console.WriteLine(kernel.Get<WebProxy>());
}
}
The full stachtrace is:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.get_ParentDefinitionMethodInfo () [0x00000] in <filename unknown>:0
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__DisplayClass1.<CreateNewPlan>b__0 (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.CreateNewPlan (System.Type type) [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+<>c__DisplayClass10.<Resolve>b__c (IBinding binding) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator27`2[Ninject.Planning.Bindings.IBinding,System.Object].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable+<CreateCastIterator>c__Iterator17`1[System.Net.WebProxy].MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[WebProxy] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[WebProxy] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at Ninject.ResolutionExtensions.Get[WebProxy] (IResolutionRoot root, Ninject.Parameters.IParameter[] parameters) [0x00000] in <filename unknown>:0
at PingApp.Schedule.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
I found other class (such as Program class itself) works well with NInject, currently the only exception is System.Net.WebProxy class. Since I didn't see any .ctor calls in the stacktrace, it doesn't seem a problem with constructor selection, so any idea how to solve this problem?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels