Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 如何在MEF框架的构造函数中获得与AspNet核心Identity UserManager实现相同的对象_Asp.net Core_.net Core_Mef - Fatal编程技术网

Asp.net core 如何在MEF框架的构造函数中获得与AspNet核心Identity UserManager实现相同的对象

Asp.net core 如何在MEF框架的构造函数中获得与AspNet核心Identity UserManager实现相同的对象,asp.net-core,.net-core,mef,Asp.net Core,.net Core,Mef,我正在使用ASPNET.Core.Identity UserManager作为类中的构造函数参数 public class UserService { [ImportingConstructor] public UserService(UserManager<ApplicationUser> userManager) { } } 公共类用户服务 { [导入构造函数] 公共用户服务(用户管理器用户管理器

我正在使用ASPNET.Core.Identity UserManager作为类中的构造函数参数

public class UserService
    {
        [ImportingConstructor]
        public UserService(UserManager<ApplicationUser> userManager)
        {

        }
    }
公共类用户服务
{
[导入构造函数]
公共用户服务(用户管理器用户管理器)
{
}
}
当我使用解析MEF容器时

UserService= container.GetExportedValue<UserService>();
UserService=container.GetExportedValue();
我收到一个错误,因为“‘未找到与约束匹配的导出’”

我的问题是如何在不初始化usermanager对象的情况下获取usermanager对象

正如我在许多关于ASPNET.Core.Identity UserManager的示例中所看到的,UserManger对象是在Startup类中配置的,使用依赖项注入,我们可以在构造函数中获得该对象。如何在MEF中执行相同的操作