diff --git a/Directory.Build.props b/Directory.Build.props
index dea0a6c6f7..94e58ab692 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,15 +3,15 @@
5.0.0
-
+
- 16.6.1
+ 16.8.3
4.2.2
- 3.0.2
+ 4.0.1
2.4.1
@@ -20,7 +20,7 @@
2.4.1
- 2.4.2
+ 2.4.3
2.2.14
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo.Abp.AspNetCore.Mvc.UI.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo.Abp.AspNetCore.Mvc.UI.csproj
index 208cfa1376..ad0066db55 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo.Abp.AspNetCore.Mvc.UI.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo.Abp.AspNetCore.Mvc.UI.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
index fde96ac65c..53e3c7f503 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
@@ -29,7 +29,7 @@
-
+
diff --git a/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj b/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj
index bd5cffe848..9f028d31ee 100644
--- a/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj
+++ b/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj
@@ -21,7 +21,7 @@
-
+
diff --git a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs
index 024fc3a258..a51637e3e7 100644
--- a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs
+++ b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs
@@ -1,6 +1,6 @@
// This software is part of the Autofac IoC container
// Copyright © 2015 Autofac Contributors
-// http://autofac.org
+// https://autofac.org
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -24,9 +24,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Autofac.Builder;
using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp;
using Volo.Abp.Modularity;
namespace Autofac.Extensions.DependencyInjection
@@ -45,16 +48,62 @@ namespace Autofac.Extensions.DependencyInjection
/// The into which the registrations should be made.
///
///
- /// The set of service descriptors to register in the container.
+ /// A container builder that can be used to create an .
///
public static void Populate(
- this ContainerBuilder builder,
- IServiceCollection services)
+ this ContainerBuilder builder,
+ IServiceCollection services)
{
- builder.RegisterType().As();
- builder.RegisterType().As();
+ Populate(builder, services, null);
+ }
+
+ ///
+ /// Populates the Autofac container builder with the set of registered service descriptors
+ /// and makes and
+ /// available in the container. Using this overload is incompatible with the ASP.NET Core
+ /// support for .
+ ///
+ ///
+ /// The into which the registrations should be made.
+ ///
+ ///
+ /// A container builder that can be used to create an .
+ ///
+ ///
+ /// If provided and not then all registrations with lifetime are registered
+ /// using
+ /// with provided
+ /// instead of using .
+ ///
+ ///
+ ///
+ /// Specifying a addresses a specific case where you have
+ /// an application that uses Autofac but where you need to isolate a set of services in a child scope. For example,
+ /// if you have a large application that self-hosts ASP.NET Core items, you may want to isolate the ASP.NET
+ /// Core registrations in a child lifetime scope so they don't show up for the rest of the application.
+ /// This overload allows that. Note it is the developer's responsibility to execute this and create an
+ /// using the child lifetime scope.
+ ///
+ ///
+ public static void Populate(
+ this ContainerBuilder builder,
+ IServiceCollection services,
+ object lifetimeScopeTagForSingletons)
+ {
+ if (services == null)
+ {
+ throw new ArgumentNullException(nameof(services));
+ }
- Register(builder, services);
+ builder.RegisterType().As().ExternallyOwned();
+ var autofacServiceScopeFactory = typeof(AutofacServiceProvider).Assembly.GetType("Autofac.Extensions.DependencyInjection.AutofacServiceScopeFactory");
+ if (autofacServiceScopeFactory == null)
+ {
+ throw new AbpException("Unable get type of Autofac.Extensions.DependencyInjection.AutofacServiceScopeFactory");
+ }
+ builder.RegisterType(autofacServiceScopeFactory).As();
+
+ Register(builder, services, lifetimeScopeTagForSingletons);
}
///
@@ -64,18 +113,33 @@ namespace Autofac.Extensions.DependencyInjection
/// The object registration style.
/// The registration being built.
/// The lifecycle specified on the service registration.
+ ///
+ /// If not then all registrations with lifetime are registered
+ /// using
+ /// with provided
+ /// instead of using .
+ ///
///
/// The , configured with the proper lifetime scope,
/// and available for additional configuration.
///
private static IRegistrationBuilder