0

Possible Duplicate:
Ioc/DI - Why do I have to reference all layers/assemblies in entry application?

I've decided to build a new MVC 3 application using Autofac as the DI container.

Since all my container configuration is done within the MVC project it forces a reference to all layers e.g. Data, which ideally the web project should have no idea about.

Is there a simple way to move this to a separate "fabric" class library? The problem I'm encountering is that I can't then configure the controllers in the fabric project as it would result in a circular reference between Fabric and MVC projects.

I understand that the reference is only used for configuration but not having the references will ensure a naughty developer doesn't start referencing the classes directly.

On a related note does anyone have any feelings about abstracting their DI container - or is this just getting carried away! As a rule of thumb I think it's good practise to wrap third party assemblies but at this level?

Thanks in advance,

Tom.

Community
  • 1
  • 1
Tom Miller
  • 435
  • 8
  • 18

1 Answers1

4

Since all my container configuration is done within the MVC project it forces a reference to all layers e.g. Data, which ideally the web project should have no idea about.

If you don't reference those layers, how do you expect the corresponding assemblies end up in your bin folder at runtime? You shouldn't be worried for referencing those layers in the MVC application.

but not having the references will ensure a naughty developer doesn't start referencing the classes directly.

You should teach your developers good practices.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • That's why I thought of having a Fabric class library that references my layers which is then referenced by the web project which would cause the assemblies to be copied to the bin folder at runtime. Thanks for your advice though as it sounds like it just isn't required. – Tom Miller Mar 07 '12 at 16:50