Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems Ninject didn't throw an exception as it generally does when your IOC dependencies aren't quite set up right. Instead it made it look like I hadn't registered the WebAPI dependency resolver which I certainly did. Here was my solution to this problem but from what I've found it could be MANY DIFFERENT types of setup issues. Just re-check everything in the dependency chain. Hopefully it helps someone!</p> <p>The controller:</p> <pre><code>public class ContestsController : ApiController { //Ninject wouldn't inject this CTOR argument resulting in the error public ContestsController(IContestEntryService contestEntryService) { </code></pre> <p>The dependency:</p> <pre><code>public class ContestEntryService : IContestEntryService { public ContestEntryService(IContestsContext contestsContext) { </code></pre> <p>The incorrect configuration:</p> <pre><code> private static void RegisterServices(IKernel kernel) { kernel.Bind&lt;IContestsContext&gt;() .To&lt;ContestsContext&gt;() .InRequestScope(); kernel.Bind(x =&gt; x.FromAssembliesMatching("MyNameSpace.*") .SelectAllClasses() .BindAllInterfaces() ); </code></pre> <p>The correct configuration:</p> <pre><code> private static void RegisterServices(IKernel kernel) { kernel.Bind(x =&gt; x.FromAssembliesMatching("MyNameSpace.*") .SelectAllClasses() .BindAllInterfaces() ); kernel.ReBind&lt;IContestsContext&gt;() .To&lt;ContestsContext&gt;() .InRequestScope(); </code></pre> <p>Generally Ninject is pretty good about reporting these sorts of errors so I really got thrown for a loop on this one!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload