Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ninject.Mvc5 does not work with mono #41

Closed
mtangoo opened this issue Jun 4, 2015 · 2 comments
Closed

Ninject.Mvc5 does not work with mono #41

mtangoo opened this issue Jun 4, 2015 · 2 comments

Comments

@mtangoo
Copy link

mtangoo commented Jun 4, 2015

Wrongly posted it in ninject/Ninject#172
I have a problem well articulated here [1]. In summary is injection does not occur and Accessing controller from URL throws Error:

System.MissingMethodException
Default constructor not found for type OnlineShopping.WebUI.Controllers.ProductController

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x000a9] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.DefaultControllerFactory+DefaultControllerActivator.Create (System.Web.Routing.RequestContext requestContext, System.Type controllerType) [0x00015] in <filename unknown>:0 
Version Information: 4.0.1 (tarball Tue May 12 15:39:23 UTC 2015); ASP.NET Version: 4.0.30319.17020

Here are mono information

 mono --version
Mono JIT compiler version 4.0.1 (tarball Tue May 12 15:39:23 UTC 2015)
Copyright (C) 2002-2014 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:            sgen

My OS is Ubuntu 14.04 if that is of any help

[1] http://stackoverflow.com/questions/30590663/ninject-mvc5-does-not-work-with-mono/30594686#30594686

@mtangoo
Copy link
Author

mtangoo commented Jun 4, 2015

One thing I have abserved is always ninject is null. When I go to home page (http://127.0.0.1:8080/) I get following error

System.NullReferenceException
Object reference not set to an instance of an object

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): Ninject.
Exception stack trace:

full stack trace:

  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.get_ParentDefinitionMethodInfo () [0x00027] 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) [0x0001c] in <filename unknown>:0 
  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.IsDefined (System.Reflection.PropertyInfo element, System.Type attributeType, Boolean inherit) [0x0001e] in <filename unknown>:0 
  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute (System.Reflection.MemberInfo member, System.Type type) [0x00010] in <filename unknown>:0 
  at Ninject.Selection.Heuristics.StandardInjectionHeuristic.ShouldInject (System.Reflection.MemberInfo member) [0x0003b] 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) [0x0001a] in <filename unknown>:0 
  at Ninject.Selection.Selector.<SelectPropertiesForInjection>b__1 (System.Reflection.PropertyInfo p) [0x00013] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1E`1[System.Reflection.PropertyInfo].MoveNext () [0x00059] in <filename unknown>:0 
  at System.Collections.Generic.List`1[System.Reflection.PropertyInfo].InsertRange (Int32 index, IEnumerable`1 collection) [0x000ff] 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) [0x00040] in <filename unknown>:0 
  at Ninject.Planning.Strategies.PropertyReflectionStrategy.Execute (IPlan plan) [0x00017] 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) [0x00010] in <filename unknown>:0 
  at Ninject.Planning.Planner.CreateNewPlan (System.Type type) [0x00055] in <filename unknown>:0 
  at Ninject.Planning.Planner.GetPlan (System.Type type) [0x00027] in <filename unknown>:0 
  at Ninject.Activation.Context.ResolveInternal (System.Object scope) [0x000c9] in <filename unknown>:0 
  at Ninject.Activation.Context.Resolve () [0x0004e] in <filename unknown>:0 
  at Ninject.KernelBase+<>c__DisplayClass15.<Resolve>b__f (IBinding binding) [0x00012] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[Ninject.Planning.Bindings.IBinding,System.Object].MoveNext () [0x00059] in <filename unknown>:0 
  at System.Linq.Enumerable.Single[Object] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00042] in <filename unknown>:0 
  at System.Linq.Enumerable.SingleOrDefault[Object] (IEnumerable`1 source) [0x00006] in <filename unknown>:0 
  at Ninject.Planning.Targets.Target`1[System.Reflection.ParameterInfo].GetValue (System.Type service, IContext parent) [0x00038] in <filename unknown>:0 
  at Ninject.Planning.Targets.Target`1[System.Reflection.ParameterInfo].ResolveWithin (IContext parent) [0x000d6] in <filename unknown>:0 
  at Ninject.Activation.Providers.StandardProvider.GetValue (IContext context, ITarget target) [0x0005e] in <filename unknown>:0 
  at Ninject.Activation.Providers.StandardProvider+<>c__DisplayClass4.<Create>b__2 (ITarget target) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[Ninject.Planning.Targets.ITarget,System.Object].MoveNext () [0x00059] in <filename unknown>:0 
  at System.Linq.Enumerable.ToArray[Object] (IEnumerable`1 source) [0x00088] in <filename unknown>:0 
  at Ninject.Activation.Providers.StandardProvider.Create (IContext context) [0x00116] in <filename unknown>:0 
  at Ninject.Activation.Context.ResolveInternal (System.Object scope) [0x00035] in <filename unknown>:0 
  at Ninject.Activation.Context.Resolve () [0x0004e] in <filename unknown>:0 
  at Ninject.KernelBase+<>c__DisplayClass15.<Resolve>b__f (IBinding binding) [0x00012] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[Ninject.Planning.Bindings.IBinding,System.Object].MoveNext () [0x00059] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateCastIterator>c__Iterator0`1[System.Web.Mvc.IDependencyResolver].MoveNext () [0x00080] in <filename unknown>:0 
  at System.Linq.Enumerable.Single[IDependencyResolver] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00042] in <filename unknown>:0 
  at System.Linq.Enumerable.Single[IDependencyResolver] (IEnumerable`1 source) [0x00006] in <filename unknown>:0 
  at Ninject.ResolutionExtensions.Get[IDependencyResolver] (IResolutionRoot root, Ninject.Parameters.IParameter[] parameters) [0x00019] in <filename unknown>:0 
  at Ninject.Web.Mvc.NinjectMvcHttpApplicationPlugin.CreateDependencyResolver () [0x00000] in <filename unknown>:0 
  at Ninject.Web.Mvc.NinjectMvcHttpApplicationPlugin.Start () [0x0001a] in <filename unknown>:0 
  at Ninject.Web.Common.Bootstrapper.<Initialize>b__0 (INinjectHttpApplicationPlugin c) [0x00000] in <filename unknown>:0 
  at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[INinjectHttpApplicationPlugin] (IEnumerable`1 series, System.Action`1 action) [0x00010] in <filename unknown>:0 
  at Ninject.Web.Common.Bootstrapper.Initialize (System.Func`1 createKernelCallback) [0x0001a] in <filename unknown>:0 
  at OnlineShoppingStore.WebUI.App_Start.NinjectWebCommon.Start () [0x00041] in /home/stefano/Documents/developer/Hosanna/LearningCSharp/web/OnlineShoppingStore/OnlineShoppingStore.WebUI/App_Start/NinjectWebCommon.cs:25 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in <filename unknown>:0 

and at footer I get:

Version Information: 4.0.1 (tarball Thu May 28 09:08:28 UTC 2015); ASP.NET Version: 4.0.30319.17020

@mtangoo
Copy link
Author

mtangoo commented Jun 5, 2015

Updating mono to 4.3 (see link below) seem to fix the issue

http://www.mono-project.com/docs/getting-started/install/weekly-packages/

@mtangoo mtangoo closed this as completed Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant