2016-09-30 2 views
0

私は私のMVCアプリケーションエラーでシンプルなインジェクタを使用していると私は以下のエラーが表示されます。の設定アイデンティティFrameworkのApplicationUserManager

The constructor of type ApplicationUserManager contains the parameter with name 'store' and type IUserStore that is not registered. Please ensure IUserStore is registered, or change the constructor of ApplicationUserManager.

それは私がUserStoreを登録したい、私はそれを登録することがあると思いますUserManagerに送信しますが、私は何をすべきか分かりません。

私はそれがこのように見えることになっていたと思った:

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

しかし、私はその後、エラーが表示さ:

private static void InitializeContainer(Container container) 
{ 
    container.Register<IAuthorisationManager, AuthorisationManager>(); 
    container.Register<IAuthorisationRepository, AuthorisationRepository>(); 
    container.Register<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>(); 
} 

アイデンティティコンフィグ

For the container to be able to create UserStore<ApplicationUser> it should have only one public constructor: it has 2. See https://simpleinjector.org/one-constructor for more information.

をしかし、それはデフォルトのASPです。 NETコードを変更することはできません。

誰もがこのエラーを説明し、どうすればいいのか教えてください。ユーザーストアを登録するために必要な

答えて

1
container.Register<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>()); 

いますが、

+1

上記の行を追加する必要があるので、これは可能な解決策ですが、それはより多くの回避策です複数のコンストラクタを持っています。シンプルなインジェクターでアイデンティティを完全にセットアップするには、このスレッドをご覧ください:https://simpleinjector.codeplex.com/discussions/564822これはまた、さまざまなリファクタリングに関するいくつかのアドバイスを、不器用なテンプレートにも示しています。 –

関連する問題