C# Visual Studio 2015将AspNet.Identity移动到类库中

C# Visual Studio 2015将AspNet.Identity移动到类库中,c#,visual-studio-2015,asp.net-identity,C#,Visual Studio 2015,Asp.net Identity,在VS 2013中,我多次将AspNet.Identity移动到类库中,但在VS 2015中,编译器抱怨manager参数引发此异常 类型“MyNamespace.ApplicationUser”不能用作泛型类型或方法“UserManager”中的类型参数“TUser”。没有从“MyNamespace.ApplicationUser”到“Microsoft.AspNet.Identity.IUser”的隐式引用转换 在此代码中: public class ApplicationUser {

在VS 2013中,我多次将AspNet.Identity移动到类库中,但在VS 2015中,编译器抱怨manager参数引发此异常

类型“MyNamespace.ApplicationUser”不能用作泛型类型或方法“UserManager”中的类型参数“TUser”。没有从“MyNamespace.ApplicationUser”到“Microsoft.AspNet.Identity.IUser”的隐式引用转换

在此代码中:

public class ApplicationUser
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;
    }
}
公共类应用程序用户
{
公共异步任务GenerateUserIdentityAsync(用户管理器)
{
//注意authenticationType必须与CookieAuthenticationOptions.authenticationType中定义的类型匹配
var userIdentity=wait manager.CreateIdentityAsync(这是DefaultAuthenticationTypes.ApplicationOkie);
//在此处添加自定义用户声明
返回用户身份;
}
}
我所有的引用和使用语句都是一样的


发生了什么事?

我想你必须让你的ApplicationUser从IdentityUser继承。

你的ApplicationUser类是什么样子的?@GaryMcGill我更新了代码以包含ApplicationUser类