自动注册后发现一个严重的问题, 程序池回收后注册类型就丢失了.
// Autofac 初始化 var baseType = typeof(IDependency); var assemblys = AppDomain.CurrentDomain.GetAssemblies().AsParallel().ToList(); var builder = new ContainerBuilder(); builder.RegisterAssemblyTypes(assemblys.ToArray()) .Where(c => baseType.IsAssignableFrom(c) && c != baseType) .AsImplementedInterfaces() .InstancePerHttpRequest() .PreserveExistingDefaults();