M
M
Max Maximov2014-11-11 15:42:35
ASP.NET
Max Maximov, 2014-11-11 15:42:35

How to auto-register classes in Autofac?

Hello.
In an ASP.NET MVC application, I want to auto-register components in Autofac. I can't figure out how to do this. To register primitively: IMyType, MyType.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aush, 2014-11-11
@maximka19

var builder = new ContainerBuilder();
var assembly = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question