Ninject 3.0 MVC kernel scan not working

2.5k views Asked by At

What happened to kernel.Scan in Ninject 3.0?

        kernel.Scan(scanner =>
        {
            scanner.FromAssembliesMatching("LR.Service.*");
            scanner.FromAssembliesMatching("LR.Repository.*");
            scanner.BindWithDefaultConventions();
        }

Get a build error. 'Ninject.IKernel' does not contain a definition for 'Scan' and no extension method 'Scan' accepting a first argument of type 'Ninject.IKernel'

Been banging my head for hours trying to figure out what to change it to. Have not seen any good site or posts explaining how to fix this simply.

This all was working perfectly fine, some piece of ninject got upgraded. After hours of figuring out why nothing was working. I did not reinstall it(knowingly), not sure what happened, but now I've reinstalled everything to 3.0, figured it woulf be better, now I'm stuck with a lack of any help.

2

There are 2 answers

0
Yogurt The Wise On BEST ANSWER

Will be checking out this later. Think this is what i was looking for.

http://sharpfellows.com/post/Ninject-Auto-registration-is-changing-in-version-3.aspx

UPDATE:

See out my other ninject3 question on auto discovery

Ninject 3.0 MVC kernel.bind error Auto Registration

0
Faibbus On

I ran into a very similar issue recently because of some library documentation incorrectly referenced “AutoLoadModules”. I had a hard time finding out this was actually a thing from the past. And half of the accepted answer is now a dead link. So in case this can be useful to someone else…

There has been, with NInject3, several breaking changes around Ninject.Extensions.Conventions. So if you are looking for AutoLoadModules, IKernel.Scan and the like, tough luck.

Instead, you are now left with only IKernel.Bind extension method:

    _kernel = new StandardKernel();
    _kernel.Bind(s=> s.FromAssembliesMatching("LR.Service.*", "LR.Repository.*")
                      .SelectAllClasses()
                      .BindDefaultInterface());