ASP.NET Web API binding with ninject

后端 未结 11 965
Happy的楠姐
Happy的楠姐 2020-12-12 22:46

I have just installed the mvc4 rc update and I am trying to build an api application with little luck.

I am using ninject but cant get my controllers to load. I keep

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 23:10

    For someone landing here while searching '...does not have a default constructor' looking for an easy way to debug silently failing configurations:

    1. Remove constructor-injected objects until the constructor can be invoked
    2. For each of the previously injected, now uninitialized objects, invoke using:

    ServiceLocator.Current.GetInstance<[OBJ-TYPE]>()

    The offending object will cause an ActivationException with a descriptive Message. You'll have something to go for.

    Remember to remove call to ServiceLocator post-fix. Ie. this is not a recommendation to use the service locator anti pattern outside debugging.

提交回复
热议问题