我收到以下錯誤,而:無參數的構造函數存在,但統一轉到另一個,而解決
mConsumerTokenManager = (IConsumerTokenManager)container.Resolve(typeof(IConsumerTokenManager), null);
即使我有
public class InMemoryTokenManager : IConsumerTokenManager, IOpenIdOAuthTokenManager
{
private Dictionary<string, string> tokensAndSecrets = new Dictionary<string, string>();
public InMemoryTokenManager(){}
/// <summary>
/// Initializes a new instance of the <see cref="Ugi.Server.Authentication.Consumers.InMemoryTokenManager"/> class.
/// </summary>
/// <param name="consumerKey">The consumer key.</param>
/// <param name="consumerSecret">The consumer secret.</param>
public InMemoryTokenManager(string consumerKey, string consumerSecret)
{
if (String.IsNullOrEmpty(consumerKey))
{
throw new ArgumentNullException("consumerKey");
}
this.ConsumerKey = consumerKey;
this.ConsumerSecret = consumerSecret;
}
Resolution of the dependency failed, type = "DotNetOpenAuth.OAuth.ChannelElements.IConsumerTokenManager", name =
「(無)」 。 發生異常時:解析時。 異常是:InvalidOperationException - 無法構造字符串類型。您必須配置容器以提供此值。 ----------------------------------------------- At異常的時間,該容器是:
Resolving Ugi.Server.Authentication.Consumers.InMemoryTokenManager,(none)
(映射從 DotNetOpenAuth.OAuth.ChannelElements.IConsumerTokenManager,(無))的 解決參數 「consumerKey」 構造Ugi.Server.Authentication.Consumers.InMemoryTokenManager (System.String consumerKey,System.String consumerSecret) 解決System.String,(無)
見http://scottdepouw.com/blog/telling-unity-which-constructor-to-use -when-initializing-a-class /,也是http://codebetter.com/davidhayden/2008/10/28/specifying-injection-constructor-using-unity-fluent-interface-for-loose-coupling-and-poco / – 2012-03-02 16:34:27