2011-10-27 4 views
0

まずMVC3をオフに使用している場合、ここでのコードがあります:"このオブジェクトのために定義されていませんパラメータなしのコンストラクタ" Ninject

private IAppRepository appRepository; 

public SearchController(IAppRepository appRepository) 
{ 
    this.appRepository = appRepository; 
} 
:検索・コントローラー用NinjectControllerFactory

class MrBigglesworthServices : NinjectModule 
{ 
     public override void Load() 
    { 
     Bind<IAuthenticationRepository>() 
      .To<AuthenticationRepository>() 
      .WithConstructorArgument("connectionString", 
       ConfigurationManager.ConnectionStrings["VoiceDB"].ConnectionString 
       ); 

     Bind<IAppRepository>() 
      .To<AppRepository>() 
      .WithConstructorArgument("connectionString", 
       ConfigurationManager.ConnectionStrings["SessionStore"].ConnectionString 
       ); 
     } 
    } 

コンストラクタにバインド

オンラインの例で見たことに基づいて、これで十分ですが、何らかの理由で、上記のエラーが発生しています。助言がありますか?どうかありがとうございます。

答えて

1

NinjectControllerFactoryを使用していると言われているので、誤った実装を使用していると思います。代わりにhttps://github.com/ninject/ninject.web.mvc/wiki/MVC3に切り替えることを検討してください。これはNinjectとMVC3の広く使われている統合です。

関連する問題