Skip to main content

If you want to use ICommonLogServiceICommonLogService in the startupStartup.cs class, you need to get an instance from the container like this:

public IServiceProvider ConfigureServices(IServiceCollection services)  {   var container = new Container();   container.Configure(config =>   {   config.AddRegistry(new StructuremapRegistry());   config.Populate(services);   });   //Get an instance of ICommonLogService from container   ICommonLogService CommonLogService = container.GetInstance<ICommonLogService>();   //Use CommonLogService here   return container.GetInstance<IServiceProvider>();  } 

If you want to use ICommonLogService in the startup class, you need to get an instance from the container like this:

public IServiceProvider ConfigureServices(IServiceCollection services)  {   var container = new Container();   container.Configure(config =>   {   config.AddRegistry(new StructuremapRegistry());   config.Populate(services);   });   //Get an instance of ICommonLogService from container   ICommonLogService CommonLogService = container.GetInstance<ICommonLogService>();   //Use CommonLogService here   return container.GetInstance<IServiceProvider>();  } 

If you want to use ICommonLogService in the Startup.cs class, you need to get an instance from the container like this:

public IServiceProvider ConfigureServices(IServiceCollection services) { var container = new Container(); container.Configure(config => { config.AddRegistry(new StructuremapRegistry()); config.Populate(services); }); //Get an instance of ICommonLogService from container ICommonLogService CommonLogService = container.GetInstance<ICommonLogService>(); //Use CommonLogService here return container.GetInstance<IServiceProvider>(); } 
Source Link
Aman B
  • 2.4k
  • 1
  • 20
  • 28

If you want to use ICommonLogService in the startup class, you need to get an instance from the container like this:

public IServiceProvider ConfigureServices(IServiceCollection services) { var container = new Container(); container.Configure(config => { config.AddRegistry(new StructuremapRegistry()); config.Populate(services); }); //Get an instance of ICommonLogService from container ICommonLogService CommonLogService = container.GetInstance<ICommonLogService>(); //Use CommonLogService here return container.GetInstance<IServiceProvider>(); }