0

How to register unity convention based registration for to work on Multiple projects ?

I have these below projects created on my soution

iSample.Interface (All interfaces present here like ITest ,etc.)

iSample.EntityDB (Entity Frmework)

iSample.Business (Test class present here which implement iSample.Interface.ITest which I want to resolve through DI using Convention based registration)

iSample.PresentationMVC (MVC project)

iSample.UnityDI (Microsoft Unity DI)

Project References as below

  1. All the projects refer to iSample.UnityDI except iSample.PresentationMVC

  2. iSample.PresentationMVC refers to iSample.UnityDI and iSample.Interface

  3. iSample.Business refers to iSample.Interface and iSample.EntityDB

Currently I am using below code which is not working when I am separating Unity as a separate project i.e. iSample.UnityDI

container.RegisterTypes(
   AllClasses.FromAssembliesInBasePath(),
   WithMappings.FromMatchingInterface,
   WithName.Default,
   WithLifetime.ContainerControlled);

Edited : - I am using the Composition Root but I need to resolve the Dependency by loading all the module so I am not sure how to register them using convention based registration

Sourav Kumar
  • 296
  • 1
  • 10
  • I seems like I am doing something wrong in this line AllClasses.FromAssembliesInBasePath() – Sourav Kumar Jul 13 '16 at 02:03
  • 1
    Possible duplicate of [Ioc/DI - Why do I have to reference all layers/assemblies in entry application?](http://stackoverflow.com/questions/9501604/ioc-di-why-do-i-have-to-reference-all-layers-assemblies-in-entry-application) – NightOwl888 Jul 13 '16 at 06:13
  • I am using the Composition Root but I need to resolve the Dependency by loading all the module so I am not sure how to register them using convention based registration – Sourav Kumar Jul 13 '16 at 08:23
  • What do you mean by "not working"? Compile error, runtime exception, which exception? – Michael Jul 23 '16 at 17:18

0 Answers0