[英]Sequence contains more than one element 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
)
);
雖然我已經添加了Owin.Security
作為參考,但我有
using Microsoft.Owin.Security;
你能給我一些提示嗎?
請注意,您嘗試使用的接口( Microsoft.Owin.Security.IAuthenticationManager
)不在Microsoft.Owin.Security.dll
但實際上在Microsoft.Owin.dll
。 檢查頂部的兩行,告訴您命名空間和程序集。 所以你只需要添加對該程序集的引用。
對於這種情況,總是值得檢查文檔,因為命名空間並不總是等同於程序集名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.