Sunday, October 10, 2010

If you are using AutoFac and you see... "are you missing a using directive or an assembly reference" when using AutoFac

e.g if you see:

'Autofac.ContainerBuilder' does not contain a definition for 'RegisterAssemblyTypes' and no extension method 'RegisterAssemblyTypes' accepting a first argument of type 'Autofac.ContainerBuilder' could be found (are you missing a using directive or an assembly reference?)

or 
'Autofac.ContainerBuilder' does not contain a definition for 'RegisterInterface' and no extension method 'RegisterInterface' accepting a first argument of type 'Autofac.ContainerBuilder' could be found (are you missing a using directive or an assembly reference?)

or....

then check that you are using "using Autofac" at the top of the file

if you don't include this then you won't get the necessary extension methods inside your file's visible namespaces.

2 comments:

  1. You just need to add using Autofac.Integration.Mvc to have access to extension methods

    ReplyDelete
  2. add using Autofac.Integration.Mvc to top of your page

    ReplyDelete