Autofac register assembly type when type and interface are in different projects

42 Views Asked by At

I'm registering types with Autofac in C#/.NET Framework 4.8. Registering one type and mapping that to the specific interface works fine. The type and the interface are in different assemblies/projects.

var builder = new ContainerBuilder();
builder.RegisterType<DataAccess.DataRepo>().As<Interfaces.IDataRepo>();

Since I have many types in different projects, I want to automate the registration with assembly scanning.

However, I struggling to link the implementation with the interface project. As mentioned, they are in different projects.

builder.RegisterAssemblyTypes(Assembly.Load(nameof(DataAccess)))
   .As<Interfaces>(); // not working, how to specify where interface is 

This is what I am trying to do, but obviously the last line wont work, and I tried different combinations. What it the proper way to link to the interface project?

0

There are 0 best solutions below