简体   繁体   中英

Cannot resolve symbol 'Owin'

I'm currently trying to implement an AspNet.Identity Authentication in an AngularJS Single Page App. The weird thing is that in my ApplicationUserManager class , I want to use Microsoft.Owin and Microsoft.AspNet.Identity.Owin but in both cases I get a "cannot resolve symbol 'Owin'" error message.

Does anyone have an idea what is going on? I have included the dependencies in my project.json and downloaded the packages. Simplified version of the ApplicationUserManager class is this:

using Matimez.Models;
using Matimez.Models.Users;
using Microsoft.AspNet.Identity.Owin;  //Error message
using Microsoft.Owin;                  //Error message
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;


public class ApplicationUserManager : UserManager<NewUser>
{ 
    public ApplicationUserManager(IUserStore<NewUser> store)
    : base(store)
        {
        }

public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
    var appDbContext = context.Get<MyAppContext>();
    var appUserManager = new ApplicationUserManager(new UserStore<NewUser>(appDbContext));

    return appUserManager;
}
}

Here are the dependencies in my project.json as requested below:

  "dependencies": {
   "EntityFramework": "7.0.0-beta4",
   "EntityFramework.Commands": "7.0.0-beta4",
   "EntityFramework.SqlServer": "7.0.0-beta4",
   "MyApp.Models": "1.0.0-*",
   "MyApp.Services": "1.0.0-*",
   "Microsoft.AspNet.Diagnostics": "1.0.0-beta4",
   "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta4",
   "Microsoft.AspNet.Identity": "3.0.0-beta4",
   "Microsoft.AspNet.Mvc": "6.0.0-beta4",
   "Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
   "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
   "Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
   "Microsoft.AspNet.WebApi.Owin": "5.2.2",
   "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta4",
   "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
   "Microsoft.Framework.Logging": "1.0.0-beta4",
   "Microsoft.Framework.Logging.Console": "1.0.0-beta4",
   "Microsoft.Owin": "3.0.1",
   "Microsoft.Owin.Security": "3.0.1",
   "Microsoft.Owin.Security.Cookies": "3.0.1",
   "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta4",
   "Microsoft.AspNet.Identity.Owin": "2.2.1"

FYI I'm using VS Community 2015

UPDATE:

So thanks to the advice of Behnaz, I installed the necessary packages and apparently that worked. Probably one of them was missing.

However the problem now are ambiguous references for the UserManager class which exists in both Microsoft.AspNet.Identity and Microsoft.AspNet.Identity.Core.

Even though I do not have a Microsoft.AspNet.Identity.Core dependency, Microsoft.AspNet.Identity.Owin...has a reference to it, creating this weird loop. Also removing Microsoft.AspNet.Identity will not work as it is also referenced in Microsoft.AspNet.Identity.EntityFramework. How can I solve this issue?

You need to install some packages to be able to use "Owin":

Microsoft.AspNet.Identity.Owin 
Microsoft.AspNet.Identity.EntityFramework 
Microsoft.Owin.Host.SystemWeb 
Microsoft.AspNet.WebApi.Owin 
Microsoft.Owin.Security.OAuth 
Microsoft.Owin.Cors 

From the Tools menu, select Library Package Manager and then click Package Manager Console, then install the packages by using the Install-Package command:

Install-Package Microsoft.AspNet.Identity.Owin 

You can find more information in Adding ASP.NET Identity to an Empty or Existing Web Forms Project .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM