title: Convention Based Dependency Injection with Ninject 3.0.0
body: <p>I have two projects in my solution... a domain project and MVC3 web project (e.g. MyApp.Domain and MyApp.Web).  Previously, when using <strong>Ninject.Extensions.Conventions</strong> ver. 2, I was able to use the following statement in the NinjectMVC3.cs file, and required dependencies throughout my solution (both web and domain) were injected properly (e.g. IFoo automatically bound to Foo).</p>
  
  <pre><code>kernel.Scan(x =&gt;
  {
    x.FromAssembliesMatching("*");
    x.BindWith&lt;DefaultBindingGenerator&gt;();
  });
  </code></pre>
  
  <p>I have just upgraded to Ninject 3.0.0 (pre-release) and Ninject.Extensions.Conventions 3.0.0 (another pre-release) but the syntax for convention based binding has changed.  I have figured out that I can use the following statement with the new version, but it only automatically binds the convention based interfaces in MyApp.Web and not in MyApp.Domain.  The previous version bound interfaces throughout the application.  </p>
  
  <pre><code>kernel.Bind(x =&gt; x
      .FromThisAssembly()
      .SelectAllClasses()
      .BindToAllInterfaces());
  </code></pre>
  
  <p>Any clue how I can configure convention based binding with the new Ninject version?  I assume it has to do with specifying the assembly, but I have tried using <code>FromAssembliesMatching("*")</code> and it fails for everything then.</p>
  
  <p><strong>-- Edit to show my exisiting code in RegisterServices method: --</strong></p>
  
  <pre><code>private static void RegisterServices(IKernel kernel)
  {
    // This code used to work with v.2 of Ninject.Extensions.Conventions
    // kernel.Scan(x =&gt;
    // {
    //   x.FromAssembliesMatching("*");
    //   x.BindWith&lt;DefaultBindingGenerator&gt;();
    // });
  
    // This is the new v3 code that automatically injects dependencies but only for interfaces in MyApp.Web, not MyApp.Domain
    kernel.Bind(x =&gt; x.FromThisAssembly().SelectAllClasses().BindToAllInterfaces()); 
  
    // I tried this code, but it throws "Error activating IDependencyResolver" at "bootstrapper.Initialize(CreateKernel)"
    // kernel.Bind(x =&gt; x.FromAssembliesInPath(AppDomain.CurrentDomain.RelativeSearchPath).SelectAllClasses().BindToAllInterfaces());
  
    // These are dependencies in MyApp.Web that ARE being bound properly by the current configuration
    // kernel.Bind&lt;IMemberQueries&gt;().To&lt;MemberQueries&gt;();
    // kernel.Bind&lt;IGrantApplicationQueries&gt;().To&lt;GrantApplicationQueries&gt;();
    // kernel.Bind&lt;IMailController&gt;().To&lt;MailController&gt;();
  
    // These are dependencies in MyApp.Domain that ARE NOT being bound properly by the current configuration, so I have to declare them manually 
    // They used to be injected automatically with version 2 of the conventions extention
    kernel.Bind(typeof(IRepository&lt;&gt;)).To(typeof(Repository&lt;&gt;)).InRequestScope();
    kernel.Bind&lt;IUnitOfWork&gt;().To&lt;UnitOfWork&gt;().InRequestScope();
    kernel.Bind&lt;IMemberServices&gt;().To&lt;MemberServices&gt;();
    kernel.Bind&lt;IGrantApplicationServices&gt;().To&lt;GrantApplicationServices&gt;();
  
    // These are dependencies that SHOULD NOT be bound by convention as they require a different scope or have unique naming
    kernel.Bind(typeof(EfDbContext)).ToSelf().InRequestScope();
    kernel.Bind&lt;IConfigurationProvider&gt;().To&lt;WebConfigConfigurationProvider&gt;().InSingletonScope();
    kernel.Bind&lt;IAuthorizationProvider&gt;().To&lt;MyAppAuthorizationProvider&gt;();
    kernel.Bind&lt;IPrincipal&gt;().ToMethod(ctx =&gt; HttpContext.Current.User).InRequestScope();
    kernel.Bind&lt;IGrantApplicationDocumentServices&gt;().To&lt;MySpecialNameGrantAplicationDocumentServices&gt;().InRequestScope();
  }
  </code></pre>