Search code examples
c#autofacautofac-moduleautofac-configuration

Inject JSON file with Autofac


I need load a JSON file with Autofac (IoC), and I'm following the official tutorial: http://autofaccn.readthedocs.io/en/latest/configuration/xml.html#quick-start

All the code is correct, but the ConfigurationModule class is not recognized:

var builder = new ContainerBuilder();

var config = new ConfigurationBuilder();
config.AddJsonFile("appsettings.json");
var module = new ConfigurationModule(config.Build());

builder.RegisterModule(module);

Solution

  • Add the NuGet package Autofac.Configuration