我无法引用 Microsoft.Owin.Security.AuthenticationManager,为什么?

I cannot reference Microsoft.Owin.Security.AuthenticationManager, why?

我的页面出现以下错误:

Server Error in '/' Application.

The current type, Microsoft.Owin.Security.IAuthenticationManager, is an interface and cannot be constructed. Are you missing a type mapping? 

我发现我应该把这段代码放在 Unityconfig.cs 中来解决这个问题:

container.RegisterType<IAuthenticationManager>(
            new InjectionFactory(
                o => System.Web.HttpContext.Current.GetOwinContext().Authentication
            )
        );

但问题是 IAuthenticationManager 不可见

虽然我添加了 Owin.Security 作为参考,但我有

using Microsoft.Owin.Security;

你能给我一些提示吗?

请注意,您尝试使用的界面 (Microsoft.Owin.Security.IAuthenticationManager) 不在 Microsoft.Owin.Security.dll 中,但实际上在 Microsoft.Owin.dll 中。检查顶部的两行,告诉您命名空间和程序集。所以你只需要添加对该程序集的引用。

对于这种情况,始终值得检查文档,因为命名空间并不总是等同于程序集名称。